2009-12-31 89 views
2

我想從VS2010 beta 2部署我的ASP.NET MVC 2網站到IIS7。發佈工作正常,但沒有路由的工作,所以當我去到URL http://localhost/myapp/Home/Index我得到的錯誤:在IIS7上運行ASP.NET MVC 2網站的問題

HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

我部署到其使用配置了.NET的應用程序池的虛擬目錄4管理流水線模式設置爲集成框架。另外,如果我進入基本設置 - >測試連接,兩個測試都會通過。據我瞭解,它應該只是工作?

我從VS2008部署Nerd Dinner沒有任何問題,工作正常。

+0

貌似是我在這裏同樣的問題http://stackoverflow.com/questions/2854808 – Guy 2010-05-19 01:33:07

回答

0

你在發佈中包含正確的MVC dll嗎?

當我瀏覽我的MVC應用程序時遇到問題,這是因爲我沒有在bin文件夾中包含MVC dll。

+0

我只設置CopyLocal爲true System.Web.Mvc.dll程序和它再沒區別。無論如何,MVC dll的V2在GAC中。 – Charlie 2009-12-31 14:33:15

0

從我對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); 
     } 
    } 
}