MVC 4 @Scripts “does not exist”

后端 未结 24 1974
长发绾君心
长发绾君心 2020-12-12 11:20

I have just created an ASP.NET MVC 4 project and used Visual Studio 2012 RC to create a Controller and Razor Views for Index and Create Actions.

相关标签:
24条回答
  • 2020-12-12 12:11
    1. : remove view page.
    2. : add namespace webconfig (in view directory)
    3. : create view an try!

    good luck...

    0 讨论(0)
  • 2020-12-12 12:13

    When i started using MVC4 recently i faced the above issue while creating a project with the empty templates. Steps to fix the issue.

    1. Goto TOOLS --> Library Package Manager --> Packager Manager Console Paste the below command and press enter Install-Package Microsoft.AspNet.Web.Optimization Note: wait for successful installation.
    2. Goto Web.Config file in root level and add below namespace in pages namespace section. add <namespace="System.Web.Optimization" />
    3. Goto Web.Config in Views folder and follow the step 2.
    4. Build the solution and run.

    The Package mentioned in step 1 will add few system libraries into the solution references like System.Web.Optimization is not a default reference for empty templates in MVC4.

    I hope this helps. Thank you

    0 讨论(0)
  • 2020-12-12 12:16

    I solve this problem in MvcMusicStore by add this part of code in _Layout.cshtml

    @if (IsSectionDefined("scripts")) 
    {
           @RenderSection("scripts", required: false)
    }
    

    and remove this code from Edit.cshtml

     @section Scripts {
        @Scripts.Render("~/bundles/jqueryval")
    }
    

    Run the program inshallah will work with you.

    0 讨论(0)
  • 2020-12-12 12:18

    I ran into this problem, however while running the command:

    Install-Package -IncludePrerelease Microsoft.AspNet.Web.Optimization 
    

    I received the cryptic message (gotta love a great pun before the first cup of coffee):

    Install-Package : The specified cryptographic algorithm is not supported on this platform.

    I am running this on Windows XP SP3 (not by choice) and what I found was that I had to follow the instructions posted by the user artsnob on the ASP.NET Forum

    • Please uninstall the Nuget and try re-installing it. If you are unable to do this, login as an Administrator.
    • Go to Tools=> Extension Manager => Select "Nuget Package Manager" => UnInstall
    • Install it again, by searching "Nuget" => Install.
    • If it did not work, please try installing, 1.7.x version as I mentioned in the previous post (It doesn't mean, you have to use the previous version, if it works fine, we can report this bug, and get the patches for the latest version).

    Once I ran this I could then run the command line to update the Web.Optimization.

    Hope this saves someone some digging.

    0 讨论(0)
  • 2020-12-12 12:19

    I had the same issue:

    The System.Web.Optimization version I was using was outdated for MVC4 RC.

    I updated my packages using the package manager in VS 2010.

    In this MSDN blog, Mr. Andy talks about how to update your MVC 4 Beta project to MVC 4 RC. Updating my packages got the Scripts (particularly the web optimization one) to resolve for me:

    To install the latest System.Web.Optimization package, use Package Manager Console (Tools -> Library Package Manager -> Package Manager Console) and run the below command:

    Install-Package -IncludePrerelease Microsoft.AspNet.Web.Optimization
    

    Use the System.Web.Optimization file included in the package in your references.

    To update other packages: Tools menu -> Library Package Manager -> Manage NuGet Packages for Solution.

    0 讨论(0)
  • 2020-12-12 12:19

    Apparently you have created an 'Empty' project type without 'Scripts' folder. My advice -create a 'Basic' project type with full 'Scripts' folder.

    With respect to all developers.

    0 讨论(0)
提交回复
热议问题