我设置routeConfig.cs如下不被重定向到登录页面后Routeconfig.cs设置去URL调用默认页
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" }
);
,但仍当我打到网站的网址导航是我404页未找到因为我没有使用任何控制器名称和动作名称在我的url.Like www.this.com 而不是www.this.com/Home.Index.It应该reddirect我登录页面,当我把网址为www.this.com 请任何帮助。
这并不回答你的问题,但我强烈建议使用路由属性而不是routeConfig文件。他们有很多好处,包括更容易维护。 https://blogs.msdn.microsoft.com/webdev/2013/10/17/attribute-routing-in-asp-net-mvc-5/ – nurdyguy