I have a MVC 3 web application which is up and running on an IIS 7.5 web server. The home page works nice, but whenever a jQuery ajax call is used to hit an action method returning Json data the server returns a 404 error.
so url looks something like this: http://myApp/Controller/Method?page=0&pageSize=20, request method is post. The target controller has an action method decorated with a [HttpPost] attribute which returns a JsonResult.
I have added the json MIME type to IIS, and I have tried setting a RequestHandler to serve post requests (I may have made mistakes while setting the handler), and it is still not working.
The application works fine when I test it from Visual Studio on my local machine, its only after deployment to the web server that the issues arise.
It turns out I was completely off the track, and the question I asked is unelated to my issue. It responded with a 404 because the action method was restricted to answer to posts only and I was attempting to access it via a GET method. The actual ajax post
responded with a 500 internal server error which was the real deal.
It responded with a 404 because the action method was restricted to answer to posts only and I was attempting to access it via a GET method. The actual ajax post responded with a 500 internal server error which was the real deal.
Ah, ok.... So you see why is good to intercept errors!
skali__
Member
4 Points
3 Posts
IIS7.5 responds with a 404 on requests for action methods serving Json to a HTTP POST
Feb 23, 2012 12:42 PM|LINK
I have a MVC 3 web application which is up and running on an IIS 7.5 web server. The home page works nice, but whenever a jQuery ajax call is used to hit an action method returning Json data the server returns a 404 error.
so url looks something like this: http://myApp/Controller/Method?page=0&pageSize=20, request method is post. The target controller has an action method decorated with a [HttpPost] attribute which returns a JsonResult.
I have added the json MIME type to IIS, and I have tried setting a RequestHandler to serve post requests (I may have made mistakes while setting the handler), and it is still not working.
The application works fine when I test it from Visual Studio on my local machine, its only after deployment to the web server that the issues arise.
Can anyone shed some light on this?
ignatandrei
All-Star
135073 Points
21662 Posts
Moderator
MVP
Re: IIS7.5 responds with a 404 on requests for action methods serving Json to a HTTP POST
Feb 23, 2012 12:44 PM|LINK
add error handling to ajax
see http://bit.ly/mvc_ajax_jquery
skali__
Member
4 Points
3 Posts
Re: IIS7.5 responds with a 404 on requests for action methods serving Json to a HTTP POST
Feb 23, 2012 12:51 PM|LINK
I don't understand, how will this help? I know what the error is, I don't know the cause of it.
EDIT: In case its not clear, my application works fine on my local machine, its when i deploy it to the server that the issues happen.
ignatandrei
All-Star
135073 Points
21662 Posts
Moderator
MVP
Re: IIS7.5 responds with a 404 on requests for action methods serving Json to a HTTP POST
Feb 23, 2012 01:13 PM|LINK
Show us ajax code
skali__
Member
4 Points
3 Posts
Re: IIS7.5 responds with a 404 on requests for action methods serving Json to a HTTP POST
Feb 23, 2012 05:06 PM|LINK
It turns out I was completely off the track, and the question I asked is unelated to my issue. It responded with a 404 because the action method was restricted to answer to posts only and I was attempting to access it via a GET method. The actual ajax post responded with a 500 internal server error which was the real deal.
ignatandrei
All-Star
135073 Points
21662 Posts
Moderator
MVP
Re: IIS7.5 responds with a 404 on requests for action methods serving Json to a HTTP POST
Feb 24, 2012 03:47 AM|LINK
Ah, ok.... So you see why is good to intercept errors!