Renaming default.aspx

Topics: ASP.NET 2.0, Themes
Jan 3, 2011 at 1:17 PM
Hi Guys, My home page is named home.aspx and want to rename the default.aspx page to blog.aspx What's the easiest way to go about this? Is it possible to do using search and replace? Thanks!
Jan 26, 2011 at 2:38 AM

Hi!

I did a similar functionality to my blog. You shouldn't do a search and replace because there are a lot functionalities pointing to default.aspx and you might break more than intended.

Here is how I would implement your changes:

1. Copy default.aspx to blog.aspx. Don't forget to rename the class name in code behind. This would ensure that all the functionalities of the default page is intact. Then add your modifications to blog.aspx.

2. On the OnLoad event of the default.aspx, add this code: Server.Transfer("blog.aspx");

This way all the other codes referring to default.aspx would still work but the default.aspx page will take them to your new blog.aspx.

Hope it helps!

Feb 1, 2011 at 12:28 PM

Galagerardo,

I would like to achieve a similar thing could you possibly elaborate showing me where within the onload event handler I can add this snippet. As I have added it to teh code behind file in the onLoad event handler and I just get error messages.

 

Thanks

Feb 1, 2011 at 2:32 PM
Edited Feb 1, 2011 at 6:43 PM

Hi Max10enb!

In your case, I would modify the default.aspx file to this:

    protected override void OnLoad(EventArgs e)
    {
        Server.Transfer("myNewDefaultPage.aspx");  //myNewDefaultPage.aspx is the name of the page that you want to default to.
    } 

Don't modify the other files refencing to default.aspx.

Hope it helps!