Link to home
Start Free TrialLog in
Avatar of Newbis
Newbis

asked on

ASP.NET MVC 4 application web services missing (404 error) on IIS7 / Windows Server 2008

I've written an ASP.NET MVC 4 application, which works on my development machine.  But when I deploy it to a server running IIS7, the controller used for Ajax calls gets a 404 error.  (I published the site to a deployment package, then imported in IIS to create the web application on the server.  The 404 errors can be seen either through FireBug, or by going to the link directly through a browser.  In the code, I'm using jQuery's ajax method and specifying "POST".  Firebug shows that the correct URL is being posted to, but with a 404 error.)

My first inclination was to think that this must be a routing problem, which it may still be.  However, the routing for "normal" pages seems to work.  For example, for the home page, and another page, the controllers and views seem to be working properly.

The difference between the controllers that work and the one that doesn't is that the one used for API-type calls gives 404 errors.  For example, the main page has methods that begin like this:

        public ActionResult Index()
        { //etc...

Open in new window


But the controller having a problem is called API-style (even though it's a regular controller, not a Web API page):

        [HttpPost]
        public JsonResult UnprocessedList()
        { //etc...

Open in new window


The forum postings and articles I've seen so far about this sort of issue seem to focus on configurations to make routing work at all on IIS7.  But since some pages are showing up correctly, I'm think that it isn't an issue of not having the right DLLs or web.config setup for routing to be activated.

I want to emphasize also that when running from the development computer itself, through Visual Studio, this all works perfectly.

I figure that there must be some setting somewhere that must be enabled to get these API-type methods to work on IIS7.  But I'm having trouble finding any information about this.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Dan McFadden
Dan McFadden
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Newbis
Newbis

ASKER

Gee, now I feel silly.  When I look at the log, where it's next to all the correct URLs, the error in the URL popped out at me.  Somehow, in FireBug, it looked right, because it just writes the one line, but when I saw it in the log, I realized that it's wrong.  If I hard-code the right URL, it works.  So something in my code isn't getting the base URL correctly.
Avatar of Newbis

ASKER

Looking at the server log file, it's easier to spot that the URL is wrong than just looking at a single URL from FireBug, because in the log file, it's next to all the correct URLs.