根據我對ASP.NET MVC的經驗,我看到一個Default.aspx
頁面是IIS正常運行所必需的頁面。我正在使用包含在ASP.NET MVC 1模板中的頁面。不幸的是,ASP.NET MVC 2不包括此頁面(據我所知),所以你應該添加以下項目:
的Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="YourNamespace._Default" %>
<%-- Please do not delete this file. It is used to ensure that ASP.NET MVC is activated by IIS when a user makes a "/" request to the server. --%>
的Default.aspx .cs:
using System.Web;
using System.Web.Mvc;
using System.Web.UI;
namespace YourNamespace
{
public partial class _Default : Page
{
public void Page_Load(object sender, System.EventArgs e)
{
// Change the current path so that the Routing handler can correctly interpret
// the request, then restore the original path so that the OutputCache module
// can correctly process the response (if caching is enabled).
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
}
}
如果您的應用程序池的管理流水線模式設置爲經典模式而不是集成模式,也會發生此錯誤。 – 2010-11-01 15:04:40