0

I have this problem, where my @Scripts.Render and @Styles.Render Does not exist in the current context. I've tried to trouleshoot, but failed at catching the problem. Can someone help me with the code?

<head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - My ASP.NET MVC Application</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width" />
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
        <script src="~/Scripts/angular.min.js"></script>
    
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-route.js"></script>
        @*    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>*@
        <script src="~/Application/App.js"></script>
        <script src="~/Application/Routing.js"></script>
    
    </head>

     @Scripts.Render("~/bundles/jquery")
Ralle12
  • 15
  • 5
  • Is the issue exist only in the server? or exists in local system also. – ScareCrow Aug 12 '20 at 08:32
  • @ScareCrow Local system – Ralle12 Aug 12 '20 at 08:34
  • @ScareCrow It just says "The name 'Styles' does not exist in the current context" and it says that with Scripts also – Ralle12 Aug 12 '20 at 08:37
  • Does this answer your question? [The name 'Scripts' does not exists in the current context in MVC](https://stackoverflow.com/questions/23534516/the-name-scripts-does-not-exists-in-the-current-context-in-mvc) – Karan Aug 12 '20 at 08:45
  • Your config ~/Views/Web.Config needs to be added to the System.Web.Optimization namespace. Try this one may resolve the issue. – ScareCrow Aug 12 '20 at 08:45

1 Answers1

0

Please try the following

Install the "Optimization" pack and then add namespaces in the config file. Add a namespace reference in the config files like:

<add namespace="System.Web.Optimization" />

Your config ~/Views/Web.Config needs to be added the System.Web.Optimization namespace:

<system.web>
    <pages>
      <namespaces>
        <add namespace="System.Web.Optimization"/>
      </namespaces>
    </pages>
</system.web>
ScareCrow
  • 497
  • 3
  • 6