Reputation: 11
i have a css file that I want to put in my layout. in the web.config file I wrote:
<location path="App_themes/default.css">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
and in the layout.cshtml I wrote:
<style>
h2 {
color:red;
}
@Styles.Render("~/App_themes/css")
</style>
but it doesn't recognize the line: @styles.render what should I do?
Upvotes: 0
Views: 8827
Reputation: 1
Put @Styles.Render("~/App_Themes/css")
inside the head element on your layout page (_Layout.cshtml
)
Put the style h2 { color: red; }
in your style sheet that lives in theApp_Themes/css
subfolder.
Upvotes: 0
Reputation: 1
pleas run project in iis project / right Click/ properties/ web/ use local IIS web server
Upvotes: 0
Reputation: 2427
You need to read-up on Bundling and Minification to get a clear picture of what is going on, but one thing is for certain the @Styles.Render("~/App_Themes/css")
call should be done outside of the context of the <style/>
tag.
@Styles.Render("~/App_Themes/css")
<style> h2 { color: red; } </style>
Upvotes: 1