我创建了一个新的解决方案,它构建了精美的定位框架4.0但是当我运行它时,我的浏览器出现了:

无法找到资源。 说明:HTTP 404.您要查找的资源(或其中一个依赖项)可能已被删除,名称已更改或暂时不可用。请查看以下网址,确保拼写正确。 请求的网址:/

关于如何调试这个的任何想法?

有帮助吗?

解决方案

尝试添加asp.net mvc 1.0项目模板附带的default.aspx页面。我在IIS 5(XP)的计算机上运行mvc 2时出现了类似的问题,这就行了。

Default.aspx的:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="YourNamespace.Website.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.Website
{
    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);
        }
    }
}

其他提示

您无需添加上述default.aspx页面。

如果您添加并运行新的 ASP.NET MVC 2应用程序“开箱即用”,浏览器将显示此404消息。

这是因为global.asax中定义的默认路由。

routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

您可以看到它正在寻找一个名为Home的控制器和一个名为Index的操作。

创建新的项目时,您可以创建家庭控制器和索引操作(它们不在空项目中),然后创建视图对于指数行动也是如此。

我的猜测是你需要在IIS下重新注册或启用框架。 尝试从相应的框架树运行aspnet_regiis和/或确保在IIS Web扩展下允许使用正确的框架版本。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top