未findASP.NET MVC资源

我正在使用.NET Framework 4.0 + MVC2的Visual Studio 2010中的MVC项目,如果我将目标框架设置为.NET 4.0,一切正常。 但是,我的主机不提供.NET 4.0,以便部署我需要在.NET 3.5上工作的站点。

我试图将其转换为ASP.NET 3.5和一切都build立得很好,除了现在,当我尝试加载主页,我得到一个404错误说:

The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: /home Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927 

任何人都知道这是为什么?

感谢您的帮助。 绕口令

根据我对ASP.NET MVC的经验, 我发现IIS需要一个Default.aspx页面才能正常工作 。 我正在使用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); } } } 

简单的解决scheme:切换到Visual Studio 2008 + SP1 + MVC 1.这是已发布/支持的组合。 如果您的主机没有安装MVC程序集,那么他们可以并排部署,您将需要确保您的主机有.NET 3.5 SP1

如果我记得正确的VS2010 B2包括MVC *** 2 *** B2,但不是MVC *** 1 ***。

这可能是MVC程序集没有安装在您要发布的服务器上。 尝试进入你的MVC项目,然后在资源下,并将所有MVC特定程序集的属性复制本地更改为true(或只是突出显示引用下的所有内容,并将此属性设置为true)。