5

I am using MVC 3 with Visual Studio 2010 and C# 4.0. My application works correctly under IIS Express from Visual studion and when deployed to a remote production IIS 7.5 server.

When I switch to using the full IIS 7.5 server on my development system I have suddenly started to get HTTP 404 errors for the actions in two of my controllers. The other controllers function correctly. This is either running the application from Visual Studio or directly from IIS.

I can see no configuration differences.

One of the controllers that is exhibiting this behaviour is:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Configuration;
using Mbrrace.ApplicationServices.Validation;

namespace Mbrrace.WebUI.Areas.Validation.Controllers
{
    public class ValidationController : Controller
    {
        //
        // GET: /Validation/Validation/

        [HttpGet]
        public JsonResult PostcodeCheck([Bind(Prefix = "perinatalView")]AddressViewModel model)
        {

            //  postcode has already been checked for correct format
            //  now look it up to see if it exists

            if (PostcodeChecks.CheckPostcodeExists(ConfigurationManager.ConnectionStrings["CommonCodeEntities"].ConnectionString, model.Postcode))
            {
                return Json(true, JsonRequestBehavior.AllowGet);
            }

            return Json("This postcode was not found in the database", JsonRequestBehavior.AllowGet);

        }

        [HttpPost]
        public JsonResult PostcodeExtendedCheck(String Postcode)
        {

            // check if it exists or of it's sector exists (all but last two characters

            string message = PostcodeChecks.PostcodeExtendedCheck(ConfigurationManager.ConnectionStrings["MbrraceCommonCodeEntities"].ConnectionString,
                Postcode, Postcode.Substring(0, Postcode.Length - 2));
            string success = (message.Length == 0) ? "OK" : "NO";
            var result = new { Success = success, Message = message };

            return Json(result, JsonRequestBehavior.AllowGet);
        }

        public class AddressViewModel
        {
            public string Postcode { get; set; }
        }

    }
}

This behaves as expected in IIS Express and a deployed to IIS. It throws a 404 error when IIS is connected to the project for debugging.

Can anyone please shed any light on why the 404 errors are being generated?

Peter Smith
  • 5,528
  • 8
  • 51
  • 77
  • Have you set managed pipeline mode to integrated in the application pool? – levelnis Feb 25 '13 at 12:37
  • Thanks, yes, we did that as well as check for "allow 32-bit apps" – Peter Smith Feb 26 '13 at 17:08
  • Could you show the routes for those controllers? Are there any attributes on the actions? Any custom handlers running? – levelnis Feb 26 '13 at 18:33
  • Do you have [this update](http://support.microsoft.com/kb/980368) installed on your server but not installed locally? – Richard Deeming Feb 28 '13 at 15:25
  • Turn on trace logging in both the Express and 'regular' web servers to find out where it *should* be and is going on the Express server, and match the process/route on your 'regular'. Some configuration might be different. Non-'express' versions have more functionality, which is changing the behaviour. – Lizz Mar 01 '13 at 22:06
  • check this... http://stackoverflow.com/questions/6187989/asp-net-web-config-error – Shachi Mar 04 '13 at 12:05
  • We would need to see the generated requests both on IIS Express and IIS7 – Jani Hyytiäinen Mar 05 '13 at 08:58

1 Answers1

0

The first thing I am thinking is about IIS configuration. Is there an Application Pool for the site configured in Integrated Mode?

you can also try to add in the global.asax an Application_OnError and check in there the server.GetLastError

another option should be to use Glimpse to see what routing problem you could have (if it is a routing problem)

after this if you don't find the problem post some more detail of IIS configuration

Amit
  • 15,217
  • 8
  • 46
  • 68
Simone Belia
  • 253
  • 3
  • 10