简体   繁体   中英

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 ?? 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:

using System.Web.Mvc; using System.Web.Routing;

namespace AdmitsWebsite { public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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