Маршрут MVC по умолчанию запрещен в доступе ⇐ C#
-
Anonymous
Маршрут MVC по умолчанию запрещен в доступе
I have an MVC application -->MyApp, I have a controller --> mycont. When I enter my site as /MyApp/Mycont/index, it goes to the index page as expected. When I type my site as /MyApp/Mycont, I get a 403 access denied message.
Here is my route config:
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Mycont", url: "Mycont/", // also tried "Mycont" "Mycont/{action}" defaults: new { controller = "Mycont", action = "Index" }); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } The controller:
[Authorize(Roles = "Myrole")] public class MycontController : Controller { public async Task Index() { .... } } The weirdest part about this error is that I do not get a challenge response nor am I redirected to my account page. The 403 error is shown directly.
Источник: https://stackoverflow.com/questions/780 ... ied-access
I have an MVC application -->MyApp, I have a controller --> mycont. When I enter my site as /MyApp/Mycont/index, it goes to the index page as expected. When I type my site as /MyApp/Mycont, I get a 403 access denied message.
Here is my route config:
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Mycont", url: "Mycont/", // also tried "Mycont" "Mycont/{action}" defaults: new { controller = "Mycont", action = "Index" }); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } The controller:
[Authorize(Roles = "Myrole")] public class MycontController : Controller { public async Task Index() { .... } } The weirdest part about this error is that I do not get a challenge response nor am I redirected to my account page. The 403 error is shown directly.
Источник: https://stackoverflow.com/questions/780 ... ied-access
Мобильная версия