Curtis
Curtis

Reputation: 103388

Change Default "Default.aspx" to "Index.aspx" on Visual Studio 2010

Whenever I create a new Web Form on Visual Studio 2010, the default name is always "Default.aspx". This is a slight pain as I'm having to change it to "Index.aspx" each time.

How can I change this so that "Index.aspx" is the default name?

Thanks.

Upvotes: 2

Views: 5981

Answers (3)

Jonathan Williams
Jonathan Williams

Reputation: 2055

Although this does not cover all scenarios I have used the folowing code in the Gloabal.asax.cs to achieve this:

public class Global : System.Web.HttpApplication
{
    protected void Application_BeginRequest(object sender, EventArgs e)
    {
        if (Request.Url.AbsolutePath.EndsWith("/"))
        {
            Server.Transfer(Request.Url.AbsolutePath + "index.aspx");
        }
    }
}

*You must remember to remove this code when deploying the code (or wrap in DEBUG statements)!

Upvotes: 1

Ben Griswold
Ben Griswold

Reputation: 18361

You can by modifying the associated .vstemplate DefaultName element. For example, you might find the webform template you need to modify in a directory similar to the following: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Web\1033. Each template file is managed within a zip file like WebForm.zip. Unzip the contents, modify the .vstemplate DefaultName element and reapply the changes to the same templates folder. Your updates should be reflected in Visual Studio. (You might need to restart VS.)

As an alternative, you should consider creating your own template (based off the original) instead of modifying the default template.

Upvotes: 2

Albert Weinert
Albert Weinert

Reputation: 164

No, there is no way do to that in Visual Studio. You can only do that in IIS.

But, you can define a Startpage in the Property-Pages (Web) of the ASP.NET Webpplication.

Upvotes: 1

Related Questions