asp.net-mvc VS 2012 上没有 ASP.NET MVC 5 Web 应用程序模板?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20607648/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No ASP.NET MVC 5 Web Application Template on VS 2012?
提问by user1987392
I'm using Visual Studio 2012 and have just installed "Microsoft ASP.NET and Web Frameworks 2013.1 - Visual Studio".
我正在使用 Visual Studio 2012 并且刚刚安装了"Microsoft ASP.NET and Web Frameworks 2013.1 - Visual Studio"。
As expected, it added the option to create an "ASP.NET MVC 5 Empty Project". The thing is, I see no way of jump-starting an already functional "base application"as I had when I was using MVC 4 (e.g. "Asp.NET MVC 4 Web Application"). I only see an empty template.
正如预期的那样,它添加了创建"ASP.NET MVC 5 Empty Project". 问题是,我看不到像我使用 MVC 4 时那样快速启动一个已经可以运行的“基本应用程序”(例如"Asp.NET MVC 4 Web Application")。我只看到一个空模板。
I've seen answers such as:
我看过这样的答案:
And found this articleon the matter.
并找到了关于此事的这篇文章。
This is obviously not a show-stopper as I can always create the application from a scratch, but I still would like to know if it is possible to achieve that on VS 2012. Did I miss a step, or do I need VS 2013 for that? A fully functional Web application template (with authentication etc.) would be nice to dabble around MVC 5's new features or for prototyping.
这显然不是一个阻碍,因为我总是可以从头开始创建应用程序,但我仍然想知道是否有可能在 VS 2012 上实现。我错过了一步,还是我需要 VS 2013那?一个功能齐全的 Web 应用程序模板(带有身份验证等)很适合用于 MVC 5 的新功能或原型设计。
回答by Sean Lynch
After creating a new project using ASP.NET MVC 5 Empty Project, you can right click on the project, then click Add..> New Scaffolded Item..., select MVCon the left, then MVC 5 Dependenciesand choose Full dependenciesfrom the prompt.
使用 创建新项目后ASP.NET MVC 5 Empty Project,您可以右键单击该项目,然后单击Add..> New Scaffolded Item...,MVC在左侧MVC 5 Dependencies选择,然后Full dependencies从提示中选择。
This will add a default layout (Views\Shared\_Layout.cshtml), Contentfolder, Scriptsfolder with bootstrap, jquery, modernizr, etc, and other things the Web Application template creates.
这将添加默认布局 ( Views\Shared\_Layout.cshtml)、Content文件夹、Scripts带有引导程序、jquery、modernizr 等的文件夹以及 Web 应用程序模板创建的其他内容。
If you get the error "CS0103: The name 'Styles' does not exist in the current context" just add <add namespace="System.Web.Optimization"/>under <namespaces>in Views/web.config
如果您收到错误“CS0103:当前上下文中不存在名称‘样式’”,只需在Views/web.config<add namespace="System.Web.Optimization"/>下添加<namespaces>
回答by Rosdi Kasim
The answer from Sean Lynch is nice but not really complete.
肖恩·林奇的回答很好,但并不完整。
However there is this nice guy that took the time to prepare the template just like in Visual Studio 2013. You will get everything down to the bootstrap template and pre-configured database table for authentication.
然而,有一个好人花时间准备模板,就像在 Visual Studio 2013 中一样。您将把一切都归结为引导模板和预配置的数据库表以进行身份验证。
All you need to do is change the DefaultConnectionin Web.Configto you SQL Server and voila all the relevant authentication table will be created for you.
所有你需要做的是改变DefaultConnection在Web.Config你的SQL Server,瞧所有相关认证表将为您创建。
Archive of the original blog (by web.archive.org)
Update
更新
The original blog is no longer online, but thankfully his template is still online. You can download the MVC5 Template for Visual Studio 2012 Here:
原来的博客已经不在线了,幸好他的模板还在网上。您可以在此处下载 Visual Studio 2012 的 MVC5 模板:
Direct link to MVC5 Template For Visual Studio 2012
直接链接到 Visual Studio 2012 的 MVC5 模板
And here is the excerpt from the original blog:
这是原始博客的摘录:
Installing the template is very simple, there are just two steps:
安装模板非常简单,只需两步:
Copy it into the following folder of your computer (creating the directory structure if necessary):
将其复制到您计算机的以下文件夹中(如有必要,请创建目录结构):
%USERPROFILE%\Documents\Visual Studio 2012\Templates\ProjectTemplates\Visual C#\Web
%USERPROFILE%\Documents\Visual Studio 2012\Templates\ProjectTemplates\Visual C#\Web
Once you've done this, simply restart Visual Studio and you will have this template available in the dialog box to create a new project under “Visual C# > Web”.
完成此操作后,只需重新启动 Visual Studio,即可在对话框中使用此模板以在“Visual C# > Web”下创建新项目。
Now you can create applications with a little more shape than the mere empty structure provided by default and enjoy the benefits of adopting Bootstrap and its responsive design, a full membership system and user authentication, bundles, filters, some content pages, etc.
现在,您可以创建比默认提供的单纯空结构更具形状的应用程序,并享受采用 Bootstrap 及其响应式设计、完整的会员系统和用户身份验证、捆绑包、过滤器、一些内容页面等带来的好处。
回答by Anirudha Gupta
You have 2 option to fix it.
您有 2 个选项来修复它。
Install the latest 2013 version which have MVC5 support inbuilt (VS2013 missing MVC3 and ASPX file template (ASPX templates will be added in future))
stay with 2012 update 4. Read my old article to get it fixed http://geekswithblogs.net/anirugu/archive/2013/11/28/mvc-5-in-visual-studio-2012-update-4.-how-to.aspx
安装最新的 2013 版本,其中内置了 MVC5 支持(VS2013 缺少 MVC3 和 ASPX 文件模板(将来会添加 ASPX 模板))
保持 2012 年更新 4。阅读我的旧文章以修复它http://geekswithblogs.net/anirugu/archive/2013/11/28/mvc-5-in-visual-studio-2012-update-4.-how -to.aspx
回答by Paul Ayraud
I'm not using 2012 now, but rather 2013, and I see the mvc 5 template there. However, I did this a while back before I had any mvc 5 templates showing up by installing mvc 5 first. You should be able to download from http://www.asp.net/mvc/mvc5. Also make sure your target framework is set correctly. Then I updated the web config like this: You have to have the correct versions of the assemblies. I googled a lot to get this info, so it should still be available if you do some research.
我现在不使用 2012,而是使用 2013,我在那里看到了 mvc 5 模板。但是,在我通过首先安装 mvc 5 显示任何 mvc 5 模板之前,我已经这样做了一段时间。您应该可以从http://www.asp.net/mvc/mvc5下载。还要确保您的目标框架设置正确。然后我像这样更新了 Web 配置:您必须拥有正确版本的程序集。我在谷歌上搜索了很多来获取这些信息,所以如果你做一些研究,它应该仍然可用。

