简体   繁体   English

找不到mvc4资源错误

[英]mvc4 resource not found error

为什么网址http://udine.bioen.utah.edu/EarlyAdmits/Admin起作用,而所谓的等效网址http://udine.bioen.utah.edu/EarlyAdmits/Admin/Index却给出错误:找不到资源?

您必须检查路由配置,可能配置不正确

First Check Index page Exist in Admin Controller Or not ?? Admin Controller中是否存在“首次检查索引”页面? If Yes Then 如果是,那么

May Be you Have Applied Form Authentication In Your Project For the Security Purpose Which Is Not Allowing You To Direct Access Of Index Page. 出于安全考虑,您可能已在项目中应用了表单身份验证,这不允许您直接访问索引页。

In Form Authentication When You Login On Page Ticket is Generated For the Security..And For The SubSequent Request Every Time It check The Availability Of ticket Before Rendering any Page.. 在表单身份验证中,当您登录页面时,会生成安全性和后续请求的票证,每次在呈现任何页面之前都要检查票证的可用性。

You Try To Access Index Page So I think It will Not Render.. 您尝试访问索引页,所以我认为它不会呈现..

The problem is solved by adding an explicit route equivalent to the default route. 通过添加与默认路由等效的显式路由来解决该问题。 But I still don't understand why the default route doesn't work. 但是我仍然不明白为什么默认路由不起作用。

Below is my RouteConfig.cs file: 以下是我的RouteConfig.cs文件:

using System.Web.Mvc; 使用System.Web.Mvc; using System.Web.Routing; 使用System.Web.Routing;

namespace AdmitsWebsite { public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 名称空间AdmitsWebsite {公共类RouteConfig {公共静态void RegisterRoutes(RouteCollection路由){route.IgnoreRoute(“ {resource} .axd / {* pathInfo}”);

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );

        routes.MapRoute(
            name: "Export",
            url: "Admin/Export"
        );
     }
}

} }

Without the explicit route trying to access Admin/Export give a "resource not found" error 如果没有尝试访问管理员/导出的显式路由,则会出现“找不到资源”错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM