2 Replies - 229 Views - Last Post: 11 July 2019 - 07:20 AM Rate Topic: -----

#1 Exceedinglife   User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 219
  • Joined: 01-July 12

When deploying MVC app on server ajax cant find action but Localhost i

Posted 11 July 2019 - 06:53 AM

Hello everyone
I have a MVC5 application when I run it on my localhost everything works without any errors. When I publish my app then I transfer it to Windows Server 2016 I put the files in wwwroot in the IIS folder and I link everything to create a new website in IIS. I then run the website and it works. I get my javascript code to work but when I go and run my ‘ajax’ methods I get an 404 error and in the function I cannot find my controller action so the method will work. Here is my actual error: xxx.xxx.xx x.219/Parts/DoPartBookFunc?bookval=8 404 (Not Found), Failed to load resource: the server responded with a status of 404 (Not Found)
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);



Is This A Good Question/Topic? 0
  • +

Replies To: When deploying MVC app on server ajax cant find action but Localhost i

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15171
  • View blog
  • Posts: 60,720
  • Joined: 12-June 08

Re: When deploying MVC app on server ajax cant find action but Localhost i

Posted 11 July 2019 - 07:16 AM

Is the corresponding function a 'GET' function? The codebehind function name is prefaced with 'OnGet'?
Was This Post Helpful? 0
  • +
  • -

#3 DarenR   User is offline

  • D.I.C Lover

Reputation: 624
  • View blog
  • Posts: 4,170
  • Joined: 12-January 10

Re: When deploying MVC app on server ajax cant find action but Localhost i

Posted 11 July 2019 - 07:20 AM

make sure you are publishing everything-- i have noticed that i sometimes get hiccups where it said it fully published the app but it really didnt-- check all your folders for missing items ..

but 1st do what modi suggested
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1