Reputation: 5550
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?
Upvotes: 5
Views: 2018
Reputation: 253
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
Upvotes: 0