I am trying to set the Login page as my default page by doing the following, but for some reasons it fail. My default page is still set to Home controller Index() page. Can someone tell me what other things might be affecting the routing behavior?
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Session", action = "Login", id = UrlParameter.Optional }
);
}
}
Here is my session controller:
public partial class SessionController : Controller
{
//
// GET: /Session/
public virtual ActionResult Login()
{
return View();
}
public virtual ActionResult Test()
{
return View();
}
}
This is my _layout.cshtml
<body>
<header>
<div class="content-wrapper">
<div class="float-left">
<p class="site-title">@Html.ActionLink("Net-Inspect Aero Dropbox", "Index", "Home")</p>
</div>
<div class="float-right">
<nav>
<ul id="menu">
<li>@Html.ActionLink("Login", MVC.Session.Login())</li>
<li>@Html.ActionLink("Test", MVC.Session.Test())</li>
<li>@Html.ActionLink("Test2", "Login", "Session")</li>
</ul>
</nav>
</div>
</div>
</header>
<div id="body">
<section class="content-wrapper main-content clear-fix">
@RenderBody()
</section>
</div>
<footer>
<div class="content-wrapper">
</div>
</footer>
</body>
Just a side note, if i change the defaults to new { controller = "Home", action = "Index", id = UrlParameter.Optional } all those three Html actionlinks will work. However, if i set it as the way I wanted, which is Session controller Login() view, the first and the third links would not work. It seems like it knows I set the Login() view as the default so that's why the page doesn't change when I click on the links, but the html on the Login() page would not show up. It still shows what's on the Home Index() view.
(by the way, i am using T4MVC, but that should make a difference.)
Thanks for your help.