MVC styles and scripts do not exist in the current context

As a training exercise, I created an empty MVC4 application, and I create it using a website.

I am learning that this is probably not the best idea ... I copied the folders Contentand Views\Sharedinto my blog project from another, which I created using the default materials, but the following lines give me errors:

@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")

Both underlined red in my _Layout.cshtml file, error:

Name does not exist in current context

So, I went back to my default project and checked where they came from, hanging over them. The tooltip says

class System.Web.Optimization.Styles
class System.Web.Optimization.Scripts

So, I went through and installed the Web Optimization Framework in accordance with this question , but this did not fix the problem.

, , 100% , script ...

- ?

+4
1

<add namespace="System.Web.Optimization" /> web.config,

:

>  <system.web.webPages.razor>
>     <host factoryType= ... />
>     <pages pageBaseType="System.Web.Mvc.WebViewPage">
>       <namespaces>
>         <add namespace="System.Web.Mvc" />
>         <add namespace="System.Web.Mvc.Ajax" />
>         <add namespace="System.Web.Mvc.Html" />
>         <add namespace="System.Web.Routing" />
>         <add namespace="System.Web.Optimization" /> 
>       </namespaces>
>     </pages>   
>  </system.web.webPages.razor>
0

Source: https://habr.com/ru/post/1540762/


All Articles