ASP.Net MVC Error: the server responded with a status of 404 (Not Found)

Last Reply 3 months ago By dharmendr

Posted 3 months ago

Hello everyone,

I have an MVC5 application and when I run it in Localhost it runs great no errors!

When I publish it and deploy it on my server. (Windows Server 2016 and I tried AWS cloud) and put it on IIS I can get to my home page and my other links but when I run my ajax() and call an Action in my controller I get xxx.xxx.xx x.219/Parts/DoPartBookFunc?bookval=8 404 (Not Found)

when I run localhost on the server I get Failed to load resource: the server responded with a status of 404 (Not Found)

but when I debug the app locally it works. I been researching and trying a bunch of different things but so far no luck. Some I tried was @Url.action(“”,””), adding a ~ in front adding ../ in front making a global file and many other things.

If someone knows how to fix this it would be hugely appreciated.

$("#PartBook").on("change", function () {
    var selectV = $(this).val();
    var selectT = $(this).text();
    $.ajax({
        url: '/Parts/DoPartBookFunc',
        type: 'GET',
        dataType: 'json',
        data: { bookval: selectV },
        //contentType: 'application/json; charset=utf-8',
        success: function (data) {
        //alert("s" + data.PartNextNumber);

 

Posted 3 months ago
bigbear says:
url: '/Parts/DoPartBookFunc',

Change with 

url: '~/Parts/DoPartBookFunc',

or use

@Url.Action("DoPartBookFunc", "Parts")