MVC default Route Denied Access

44 Views Asked by At

I have an MVC application -->MyApp, I have a controller --> mycont. When I enter my site as www.mysite.com/MyApp/Mycont/index, it goes to the index page as expected. When I type my site as www.mysite.com/MyApp/Mycont, I get a 403 access denied. You do not have permission to view this directory or page using the credentials that you supplied. 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<ActionResult> Index()
    { .... }
}        

After performing an error trace I see that IIS cycles looking for the following pages: /MyApp/Mycont/default.htm .../default.aspx ../index.htm but does not look for .../index.cshtml It apparently tries to open the directory ../MyApp/Mycont/. Why is IIS ignoring the MVC controller action?

0

There are 0 best solutions below