How to associate custom file extension with VWD Web Form editor

So you have files with .foo extension which you want to behave like they are .aspx in Visual Studio and at runtime? Here is how to make it happen. Let's say you have default.foo file.

1. Open your Web site in VS or Visual Web Developer

2. Tools | Options | Text Editor | File Extensions

3. Type foo in the extension field, choose Web Form Editor from the editor list and click Add and click OK

Now open your Web site web.config file (add one if you don't yet have it) and check that you have registered .foo with the ASP.NET runtime. If not, add same handler and build provider that is registered for .aspx extension:

    <system.web>
<compilation>
<buildProviders>
<add extension=" .foo" type="System.Web.Compilation.PageBuildProvider" appliesTo="Web" />
</buildProviders>
</compilation>
<httpHandlers>
<add path="* .foo" verb="*" type="System.Web.UI.PageHandlerFactory" validate="True" />
</httpHandlers>
</system.web>

Save the file, open default.foo and observe intellisense, coloring and debugging working. Enjoy :-)