0

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?

user2421945
  • 11
  • 2
  • 3

3 Answers3

1

See Styles.Render in MVC4.

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>
Community
  • 1
  • 1
Roberto Hernandez
  • 2,397
  • 1
  • 16
  • 18
0

pleas run project in iis project / right Click/ properties/ web/ use local IIS web server

Mehri
  • 1
0

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.

ernd enson
  • 1,764
  • 1
  • 14
  • 29