Search code examples
c#asp.net-mvcrazorasp.net-mvc-routing

Asp.net MVC Routing Issue 403.14


one of my controller could not load "Index".for example :

 http://localhost:51638/Reserve/

doesn't work.but http://localhost:51638/Reserve/Index works. and this problem is just for one of my controller and other is correct. and my RouteConfig is:

public static void RegisterRoutes(RouteCollection routes)
        {


            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // BotDetect requests must not be routed
            routes.IgnoreRoute("{*botdetect}",
              new { botdetect = @"(.*)BotDetectCaptcha\.ashx" });
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "UserHome", action = "Index", id = UrlParameter.Optional }
            );
        }

after delete the controller and add Controller again it wasn't fix. and encounter to this error page:

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.

and this is my Controller Code

public class ReserveController : Controller
{
    //
    // GET: /Reserve/
    public ActionResult Index()
    {
        return View();
    }
}

Solution

  • If you have controller named ReserveController, and a directory named Reserve, the routing will go to the directory unless you supply the full route. This is why you get the 403.14 error.

    So, change the name of the controller or the directory.