how to set start page using webconfig file .I have tried this code
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear />
<add value="index.aspx"/>
</files>
</defaultDocument>
</system.webServer>
But it didnot work for me . I have set start page by right click on page in solution explorer then choose option set as start page but how can i do it programmatically
This question is related to
asp.net
configuration
web-config
The same problem arrised for me when I installed Kaliko CMS Nuget Package. When I removed it, it started working fine again. So, your problem could be because of a recently installed Nuget Package. Uninstall it and your solution will work just fine.
the following code worked fine for me. kindly check other setting in your web config
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="Login.aspx"/>
</files>
</defaultDocument>
</system.webServer>
If your project contains a RouteConfig.cs file, then you probably need to ignore the route to the root by adding routes.IgnoreRoute("");
in this file.
If it doen't solve your problem, try this :
void Application_BeginRequest(object sender, EventArgs e)
{
if (Request.AppRelativeCurrentExecutionFilePath == "~/")
Response.Redirect("~/index.aspx");
}
I think this will help
<directoryBrowse enabled="false" />
<defaultDocument>
<files>
<clear />
<add value="index.aspx" />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="index.html" />
<add value="iisstart.htm" />
<add value="default.aspx" />
<add value="index.php" />
</files>
</defaultDocument>
</system.webServer>
You can achieve it by code also, In you Global.asax file in Session_Start event write response.redirect to your start page like following.
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Response.Redirect("~/Index.aspx");
}
You can get redirect page name from database or any other storage to change the application start page while application is running no need to edit web.config or change any IIS settings
Source: Stackoverflow.com