locked
how to add reference to styles in the layout page in MVC RRS feed

  • Question

  • Good day guys, i want to add reference to style sheets in my layout page using razor but it isn't working. is there a plugin i'm supposed to install or something?

    here's the code

    in the head tag of the layout page, i'm supposed to add something like this in order to reference the stylesheet

     @Styles.Render("~/Content/css")

    but when i type this

    @styles

    the application tells me that this doesn't exist in the current context. pls any tip would help. thanks


    Easy

    Saturday, October 24, 2015 10:14 AM

Answers

  • Hello there

    Make sure that the System.Web.Optimization.dll assembly has been referenced in your project and that the <add namespace="System.Web.Optimization"/> namespace has been added to your ~/Views/web.config file (not ~/web.config file):

    Cheers

    Dinesh

    • Proposed as answer by Dinesh Gabhane Saturday, October 24, 2015 11:10 AM
    • Marked as answer by EasyHero Saturday, October 24, 2015 11:52 AM
    Saturday, October 24, 2015 11:10 AM

All replies

  • Hello there

    Make sure that the System.Web.Optimization.dll assembly has been referenced in your project and that the <add namespace="System.Web.Optimization"/> namespace has been added to your ~/Views/web.config file (not ~/web.config file):

    Cheers

    Dinesh

    • Proposed as answer by Dinesh Gabhane Saturday, October 24, 2015 11:10 AM
    • Marked as answer by EasyHero Saturday, October 24, 2015 11:52 AM
    Saturday, October 24, 2015 11:10 AM
  • Hi  Easy,

    For questions related to ASP.NET use the ASP.NET forum http://forums.asp.net      
    You should get more, better and faster answers on the other forum if you have new issues related to Asp.Net next time. 

    .

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 26, 2015 3:32 AM