如果我手动设置Response.StatusCode,IIS重写我的响应内容
问题 当我手动设置我的响应stream的HTTP Status为404或503 ,IIS呈现股票IIS内容/视图,而不是我的自定义视图。 当我用Web开发服务器(AKA。Cassini)做这件事时,它能正常工作(也就是说,我的内容被显示, response.statuscode ==我input的数据)。 有什么办法可以重写这种行为? 如何复制 制作一个默认的ASP.NET MVC1 web应用程序。 添加以下路线 public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", "{*catchall}", new { controller = "Home", action = "Index" } ); } 现在使用…replaceHomeController的Index方法 [HandleError] public class HomeController : Controller { public ActionResult Index() { Response.StatusCode = 404; return View(); } }