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();
}
}
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With