我将 MVC 3 与 Visual Studio 2010 和 C# 4.0 一起使用。我的应用程序在 Visual studion 的 IIS Express 下以及部署到远程生产 IIS 7.5 服务器时可以正常工作。
当我切换到在我的开发系统上使用完整的 IIS 7.5 服务器时,我的两个控制器中的操作突然开始出现 HTTP 404 错误。其他控制器正常工作。这是从 Visual Studio 或直接从 IIS 运行应用程序。
我看不到配置差异。
表现出这种行为的控制器之一是:
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; }
}
}
}
这在 IIS Express 和部署到 IIS 中的行为符合预期。当 IIS 连接到项目进行调试时,它会引发 404 错误。
任何人都可以解释为什么会产生 404 错误吗?