Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 01, 2013 09:45 AM by Mikesdotnetting
Jan 01, 2013 03:51 AM|LINK
I was trying to port a classic ASP site to .net Web Pages, and wondered if it's possible to use .htm file extensions and still have them handled by Razor. The equivalent is a snap in classic ASP, just adding a handler mapping. I consider this to be standard
good practice, because if the website ever needs to be moved to a new platform years in the future, one need not worry about broken bookmarks, lost search engine listings etc. if the pages are always .htm.
I tried the dumb-nuts approach of just adding handler mappings for .htm equivalent to what was there for .cshtml, but the net result is that .htm pages are just served up with source code, not processed. Is there some directive within the pages that would
cause the razor engine to get involved?
My dev environment is 2008 server R2, IIS 7.5, and VWD 2010 Express. I followed the steps indicated to load Web Pages without Webmatrix (installing MVC 3 etc.)
Jan 01, 2013 08:05 AM|LINK
Web Pages (.cshtml and .vbhtml files) are mapped to the WebPageHttpHandler based on their file extensions during PreApplicationStart. You cannot register other extensions after this code has run. There is no API to this event, either, so writing Razor code
in .htm files is not an option that is available to you, I'm afraid.
An easier way of managing legacy URLs in ASP.NET is through URL rewriting: http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module
Jan 01, 2013 09:25 AM|LINK
Is this something that would ever be fixed in a future release of any flavor of asp.net?
Does Microsoft even recognize this as a shortcoming?
It's depressing how an obviously smart feature of the old technology is rubbed out in the new. Everything becomes legacy sooner or later. Why make it hard to handle?
Jan 01, 2013 09:45 AM|LINK
If you think it should be included in the Web Pages framework, you should suggest it at the User Voice site: http://webmatrix.uservoice.com/forums/128313-webmatrix-suggestions.
But I think it's unlikely to be considered because of the different compilation models inherent in classic ASP and ASP.NET.