MVC3找不到资源

发布于 2024-11-30 22:15:32 字数 983 浏览 1 评论 0原文

我正在尝试启动一个 mvc3 网站。但是当我加载服务器时我收到此错误。

描述:HTTP 404。您正在查找的资源(或其其中之一) 依赖项)可能已被删除,其名称已更改,或者是 暂时无法使用。请检查以下 URL 并进行 确保拼写正确。

我的路线文件看起来像这样

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
               "Default",                                              // Route name
               "{controller}/{action}/{id}",                           // URL with parameters
               new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
           );
            routes.MapRoute(
               "States",                                              // Route name
               "{controller}/{action}/{id}",                           // URL with parameters
               new { controller = "States", action = "Index", id = "" }  // Parameter defaults
           );
        }

I'm trying to start a mvc3 website. But when I load the server I get this error.

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.

My routes file looks like this

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
               "Default",                                              // Route name
               "{controller}/{action}/{id}",                           // URL with parameters
               new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
           );
            routes.MapRoute(
               "States",                                              // Route name
               "{controller}/{action}/{id}",                           // URL with parameters
               new { controller = "States", action = "Index", id = "" }  // Parameter defaults
           );
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相对绾红妆 2024-12-07 22:15:32

我注意到您有两个可能存在冲突的路线注册。尝试删除第一个注册并只保留这个:

           routes.MapRoute(
               "States",
               "{controller}/{action}/{id}",
               new { controller = "States", action = "Index", id = "" }
           );

I noted that you have two possibly conflicting route registrations. Try removing the first registration and leaving only this one:

           routes.MapRoute(
               "States",
               "{controller}/{action}/{id}",
               new { controller = "States", action = "Index", id = "" }
           );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文