Remembering Thoughts
  Twitter GitHub RSS

Map .html extension to the .Net razor view engine

1. Add the buildProvider config for razor inside the compilation element

image

2. Application start –> Registers the html extension with razor

image

3. Create a Start.cshtml page and ingest the index.html page

image

<compilation debug\="true" targetFramework\="4.6" \> 
  <buildProviders\>     
    <add extension\=".html" type\="System.Web.WebPages.Razor.RazorBuildProvider"/>   
</buildProviders\> 
</compilation\>

 System.Web.Razor.RazorCodeLanguage.Languages.Add("html", new CSharpRazorCodeLanguage()); WebPageHttpHandler.RegisterExtension("html");



@{ 
  
  Layout \= null;   

  @RenderPage("~/index.html") 

}   

<!-- Version + @System.Reflection.Assembly.GetAssembly(typeof (Startup)).GetName().Version.ToString(); \-->


Published:

Share on Twitter