Wednesday, 16 March 2016

MVC - Set Default StartUp Page

1.MVC - Set Default StartUp Page

Set below code in RouteConfig.cs in App_Start folder
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional });
}

OR

Second Way : You simple follow below steps,
1) Right click on your project solution
2) Select Property
3) Select Web option and then Select Specific Page (Controller/View) and then set your login page
Here, Account is my controller and Login is my action method (saved in Account Controller)
Please take a look attachedenter image description here 2
2.ASP.NET - Set Default StartUp Page in web.conig

<system.webServer>
<defaultDocument enabled="true">
<files>
<clear />
<add value="Login.aspx"/>
</files>
</defaultDocument>
</system.webServer>
3.ASP.NET - Set Default StartUp Page in Global.asax

void Session_Start(object sender, EventArgs e)
{ // Code that runs when a new session is started Response.Redirect("~/Index.aspx");
}

No comments: