Redirect default.apsx to another page
On our site we wanted to have all of our pages under version control including the root default.aspx page so that required us to do a redirect from from the root to the /pages/default.aspx.
There are a few ways to do this.
-
The easiest is to add a content web part and add a
<script> location.href = ‘/pages/default.aspx’; </script> but not the most efficient means.
-
or create a simple web part or web control that does a
Page.Response.Redirect = “/pages.default.aspx”
-
or what we did is add this to the page
<script language=”C#” runat=”server”>
void Page_Load()
{
Response.Redirect(”/pages/default.aspx”); // DO NOT USER Server.Transfer here as it will screw up your relative references.
}</script>
NOTE: for this to work you will also need an entry in the web.config file to allow compiling. Looks like this:
<PageParserPaths>
<PageParserPath VirtualPath=”/default.aspx” CompilationMode=”Always” AllowServerSideScript=”true” />
</PageParserPaths>

Leave a Reply
You must be logged in to post a comment.