0

I set routeConfig.cs as below

routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 
        routes.MapRoute(
          name: "Default",
          url: "{controller}/{action}/{id}",
          defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
        routes.MapRoute(
        name: "404-PageNotFound",
        url: "{*url}",
        defaults: new { controller = "Error", action = "PageNotFound" }
        );

but still when I hit website url it navigate me to 404-page not found as I am not using any contoller name and action name in my url.Like www.this.com not www.this.com/Home.Index.It should reddirect me to Login page when I put url as www.this.com Any help please.

User1710
  • 191
  • 1
  • 4
  • 19
  • 1
    This doesn't answer your question but I highly recommend using routing attributes rather than the routeConfig file. They have many benefits, including being much easier to maintain. https://blogs.msdn.microsoft.com/webdev/2013/10/17/attribute-routing-in-asp-net-mvc-5/ – nurdyguy Nov 28 '16 at 18:57

1 Answers1

0

I have took answer from here:

You have to in web.config in section <system.web> add:

<customErrors mode="On" defaultRedirect="~/Home/Index" />

Did you mean this?

Community
  • 1
  • 1
Adam Shakhabov
  • 1,194
  • 2
  • 14
  • 35
  • we are redirecting to another page when error occurs so if custom Error occurs it will redirect to ~/Home/Index. we don't need this what we need is that when we put web url in url address bar it must default redirect to Home login page not error page. – User1710 Nov 30 '16 at 09:46
  • Maybe you try to prevent call action by unautorized user? – Adam Shakhabov Nov 30 '16 at 12:34