views:

87

answers:

3

I've inherited a bunch of code that has server script inside of .htm files.

On IIS, a handler mapping pumps.Htm pages though the asp.net engine.

Unfortunately, visual studio doesn't notice that they should be treated as code.

Is there any way to make VS treat .Htm files as code/aspx files?

A: 

You could rename them with an aspx extension.

Andrew Hare
Thanks, but there are about 1400 of them, many with with links from external websites.
Jason Hernandez
REN *.html *.aspx
Jason Berkan
+1  A: 

Adding a build provider under system.web/compilation allows Visual Studio to build .Htm pages.

<system.web>
    <compilation debug="true">
      <buildProviders>
        <add extension=".htm" type="System.Web.Compilation.PageBuildProvider"/>
      </buildProviders>

to get IntelliSense to (mostly) work go to: Tools->Options->Text Editor->File Extension add associate the .htm extention with the "Web Form Editor"

Jason Hernandez
A: 

Rename them to .ASPX and then ... pick one of these:-

Use URL Rewriting to rewrite incoming requests to .ASPX.

Use IIS7.5 Application and Request Routing to rewrite them to .ASPX or to 301 redirect them to the new location

Use .NET 3.5+ URL Routing to create routes for the .htm paths to WebFormRouteHandlers or to a special RedirectRoute handler

If you make both URLs active rather than redirecting, don't forget to add the canonical link element into each page if you want search engines to treat the duplicate content correctly.

Hightechrider