Pet*_*ith 5 asp.net-mvc iis-7 http asp.net-mvc-routing
我在Visual Studio 2010和C#4.0中使用MVC 3.我的应用程序在IIS Express中从Visual studion正常工作,并在部署到远程生产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; }
}
}
}
Run Code Online (Sandbox Code Playgroud)
这在IIS Express中的预期行为和部署到IIS的行为.当IIS连接到项目进行调试时,它会引发404错误.
任何人都可以详细说明为什么会产生404错误?
我首先想到的是IIS configuration
。是否有Application Pool
在集成模式下配置的站点?
您还可以尝试添加global.asax
anApplication_OnError
并在那里签入server.GetLastError
另一个选择应该是使用 Glimpse 来查看您可能遇到的路由问题(如果是路由问题)
在此之后,如果您没有发现问题,请发布 IIS 配置的更多详细信息
归档时间: |
|
查看次数: |
1719 次 |
最近记录: |