Is it possible to make visual studio treat .htm files like .aspx files? i.e. parse and compile them on build
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 notic开发者_如何转开发e that they should be treated as code.
Is there any way to make VS treat .Htm files as code/aspx files?
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"
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.
You could rename them with an aspx
extension.
精彩评论