Suppose I want to render javascript from an external file inline into my layout file for performance reasons.
If I use the following Razor code
<script>
@RenderPage("~/Content/my.js")
</script>
results in
Server Error in '/' Application.
The following file could not be rendered because its extension ".js" might not be supported: "~/Content/my.js".
If I merely rename my javascript file to my.js.cshtml
<script>
@RenderPage("~/Content/my.js.cshtml")
</script>
The peasants rejoice.
The question:
Is there any simple way for me to prevent RenderPage from nagging such that I can tell it that the .js
extension is fine?
With some feedback from @choudeshell one potential solution is:
<compilation debug="true" targetFramework="4.5">
<buildProviders>
<remove extension=".js"/>
<add extension=".js" type="System.Web.WebPages.Razor.RazorBuildProvider,
System.Web.WebPages.Razor"/>
</buildProviders>
</compilation>
What type of side effects would there be from removing whatever the default is for .js, any?