Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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();
    }
}
like image 828
Amirhossein Yari Avatar asked Jun 08 '15 11:06

Amirhossein Yari


People also ask

How do you fix the Web server is configured to not list the contents of this directory?

To do it, select Start, select Run, type inetmgr.exe, and then select OK. In IIS Manager, expand server name, expand Web sites, and then select the website that you want to change. In the Features view, double-click Directory Browsing. In the Actions pane, select Enable.


1 Answers

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.

like image 123
dbugger Avatar answered Oct 02 '22 22:10

dbugger