6

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();
    }
}
4
  • Is your Controller name UserHomeController? Commented Jun 8, 2015 at 12:12
  • Do you have a directory named Reserve under the application root? If so, the routing is getting confused. Commented Jun 8, 2015 at 12:20
  • post your controller code here, that should help. Commented Jun 8, 2015 at 12:25
  • The reason is that your Windows doesn't install sp1 package, you can check and try it. if you use Windows 7 or 2008r2, the download link is below: microsoft.com/en-US/download/details.aspx?id=5842 and choose windows6.1-KB976932 according to your system(x86, x64, ia64) For more information, please let me know Commented Dec 28, 2016 at 8:15

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

Comments

0

You can add another routhe with default route for "Reserve"

routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Reserve", action = "Index", id = UrlParameter.Optional }
            );

4 Comments

I don't want to "Reserve" page be my startup page.just I want to be available and load "Index".
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.
I don't know why but if I Change the controller name it's ok.but "Reserve" is not
@dbugger - I just had this problem adding MVC to an empty ASP.NET project and had a controller and directory with the same name. I upvoted your comment. If you put your suggestion in an answer instead of buried in a comment, we can upvote - controller/directory with same name causes this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.