Welcome to MSDN Blogs Sign in | Join | Help

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 :-)

Published Tuesday, August 23, 2005 1:43 PM by Mikhail Arkhipov (MSFT)

Comments

# re: How to associate custom file extension with VWD Web Form editor

Hi Mikhail !

"appliesTo" do not work in August CTP. Do you know the word that replace it ??

Thanks in advance.
Eugenio Serrano (ASP.Net MVP)
Argentina
Thursday, September 08, 2005 10:02 AM by Eugenio Serrano

# re: How to associate custom file extension with VWD Web Form editor

Just copy-paste whatever line exists in the web.config for aspx extension and change it to refer to your new extension.
Saturday, September 17, 2005 12:24 PM by Mikhail Arkhipov (MSFT)

# re: How to associate custom file extension with VWD Web Form editor

i want to know how associate custom file extension in my web host support asp.net and where place it? i control my web site by ftp form
Monday, December 26, 2005 2:28 PM by Mauricio

# re: How to associate custom file extension with VWD Web Form editor

web.config is where you add new file associations for the ASP.NET runtime. Basically what I described above after step 3.
Monday, December 26, 2005 2:47 PM by Mikhail Arkhipov (MSFT)

# re: How to associate custom file extension with VWD Web Form editor

I have a new extension working for WebForms, but I would like to have Solution Explorer recognize my new extension as a WebForm. How is this done? (What I mean is that I want the context menu for a WebForm on files with my new extension, and I want the code behind file grouped under the html file like aspx files).

Thanks!
Tuesday, February 21, 2006 7:18 PM by David

# re: How to associate custom file extension with VWD Web Form editor

In order to get the icon association you need to register file extension in the registry under HKEY_CLASSES_ROOT. Look at how .aspx is registered: it points OpenWithProgid to VisualStudio.aspx.8.0, which key is under the same root and contains point to the icon (as a dll name and # of icon in the dll resources.

Have a look here: http://blogs.msdn.com/mikhailarkhipov/archive/2005/08/10/449799.aspx on how to make files appear as cascading icons in the Solution Explorer.
Sunday, February 26, 2006 1:33 AM by Mikhail Arkhipov (MSFT)
New Comments to this post are disabled
 
Page view tracker