從我對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);
}
}
}
貌似是我在這裏同樣的問題http://stackoverflow.com/questions/2854808 – Guy 2010-05-19 01:33:07