VS2010升级VS2012必备(MVC4 WebPage2.0 Razor2.0资料汇集)
刚把项目升级到2012,发现发生了很多变化,以下是最近看过的网站和资料汇集,供需要者参考。
本文在最近一个月可能会不断更新。
Razor2.0
WebPage2.0
MVC3到MVC4升级中遇到的问题汇总
登录机制换了,和用户相关的操作会出现一些错误
var users = new UsersContext().UserProfiles.ToList();
userContext.UserProfiles.Remove(user);
userContext.SaveChanges();
2. 所有[Authorize[Roles="XXX"]的地方会出错。
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
并把它挪到(此语句只能调用一次,故需要挪动,或注释掉):
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas(); AuthConfig.RegisterAuth();
... WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
}
另外在一个叫做 FilterConfig.cs文件中,请加上第二句话:
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new InitializeSimpleMembershipAttribute());
}
}
原文见:http://stackoverflow.com/questions/12342398/simplemembership-mvc4-authorizeattribute-and-roles
Razor的一些小改动
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
如果想沿用原来自己的Layout,可以删除这句话,就会继续调用原来的Layout了。
Layout = "~/Views/Shared/_Layout.cshtml";
这句话,在任何其他地方设置Layout可能会导致错误,但不报错!只是从此处以后的内容不再显示。
Layout = "~/Views/Shared/_Layout.cshtml";
LocalDB数据库升级
In Server Explorer, choose the Connect to Database button.
In the Add Connection dialog box, specify the following information:
Data Source: Microsoft SQL Server (SqlClient)
Server Name: (LocalDB)\v11.0
Attach a database file: Path, where Path is the physical path of the primary .mdf file.
Logical Name: Name, where Name is the name that you want to use with the file.
Choose the OK button.
When prompted, choose the Yes button to upgrade the file.
如果不行,请参考原文:http://msdn.microsoft.com/en-us/library/hh873188.aspx
VS2010升级VS2012必备(MVC4 WebPage2.0 Razor2.0资料汇集)的更多相关文章
- vs2010 打开 vs2012 的解决方案
vs2010 打开 vs2012 的解决方案 vs2012 出来了,但是MS还是一如既往的向下兼容. 废话不多说,直接主题 要使用vs2010打开vs2012的解决方案必须得改2个东西,解决方案 ...
- vs2010 和vs2012的区别 副标题--Loaded事件走两次
我上一遍博文没有通过首页显示!这边就简短的描述一下问题,希望大拿们有遇到类似问题或者知道原因的回答一下下!!! 最终的问题是Loaded事件走两次,具体可以看我上一篇对问题的描述. 在目标框架同样都是 ...
- 20140402 cmake编译错误原因 同时装了vs2010和vs2012
1.cmake编译错误原因 在用cmake编译opencv出现的错误 The CXX compiler identification is MSVC 16.0.30319.1 The C compil ...
- Oracle_RAC数据库GI的PSU升级(11.2.0.4.0到11.2.0.4.8)
Oracle_RAC数据库GI的PSU升级(11.2.0.4.0到11.2.0.4.8) 本次演示为升级oracle rac数据库,用GI的psu升级,从11.2.0.4.0升级到11.2.0.4.8 ...
- VS2010 打开 VS2012 的项目
用 VS2010 打开 VS2012 项目,只需两步. 1. 修改解决方案文件(*.sln) 使用记事本打开 *.sln 文件,将里面的 Microsoft Visual Studio Solutio ...
- 示例Oracle 10.2.0.1.0升级到10.2.0.4.0一例
1.查看当前系统版本 [oracle@std Disk1]$ sqlplus '/as sysdba' SQL*Plus: Release - Production on Thu Jan :: Cop ...
- Asp.net Core 1.0.1升级到Asp.net Core 1.1.0 Preview版本发布到Windows Server2008 R2 IIS中的各种坑
Asp.net Core 1.0.1升级到Asp.net Core 1.1.0后,程序无法运行了 解决方案:在project.json中加入runtime节点 "runtimes" ...
- 升级_宽视野Oracle图形升级(升级后dbca建库)—10.2.0.1.0提拔10.2.0.5.0
***********************************************声明********************************************** 原创作 ...
- .net: 不能忽视的break——寻找VS2010和VS2012编译器的一个小区别
文中的问题来自于实际开发,但是实际开发中的代码逻辑比较复杂,因此下面的代码去掉了所有逻辑,只保留能体现问题的代码,类和都只为了说明问题,并不具有实际意义.下面首先看看下面的代码和现象. 1. 问题再现 ...
随机推荐
- [Angular 2] ROUTING IN ANGULAR 2 REVISITED
Let's say we have a list of contacts, click each contact, we can render a new route to get the detai ...
- iOS/object-c: 枚举类型 enum,NS_ENUM,NS_OPTIONS
一般情况下,我们采用C风格的enum关键字可以定义枚举类型. enum{ UIViewAnimationTransitionNone, UIViewAnimationTransitionFlipFro ...
- 利用java开发一个双击执行的小程序
之前我们利用java写了很多东西,但是好像都没有什么实际意义. 因为有意义桌面小程序怎么都得有个界面,可是界面又不太好搞.或者 了解到这一层的人就少之又少了. 呀,是不是还得开辟一些版面来介绍awt和 ...
- linux安装java环境
在linux下安装JDK如下: 第一步:查看Linux自带的JDK是否已安装 (1)查看已经安装的jdk: [root@web-server ~]# rpm -qa|grep jdk ← 查看jdk的 ...
- StyleCop安装及配置
How to modify the default new class template for C# in Visual Studio 2008 or 2010? 可参考博客: http://www ...
- Java Mybatis 传参方式
一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...
- C# 调用Java Webservice 加入SoapHeader 验证信息
C#调用java 编写的webservice时不会自动生成 soapheader 类接口的,需要改动Reference.cs. 在生成的代理类referende.cs中进行如下操作: 一.在声明pub ...
- 更靠谱的js判断浏览器及其版本
所有的前端开发人员都没有办法回避一个问题,那就是浏览器版本判断,当我们无法回避需要进行浏览器版本判断时,前辈们往往会告诉我们,可以判断 UserAgent这个用来标示浏览器的字符串,通过判断这一字符串 ...
- ios PromiseKit
简介: 高级开发是高度异步的,PromiseKit收集了一些帮助函数,让我们开发过程中使用的典型异步模式更加令人愉悦. 1.通过pod安装promisekit: 2. promise.h介绍 @imp ...
- ios Object Encoding and Decoding with NSSecureCoding Protocol
Object Encoding and Decoding with NSSecureCoding Protocol February 27, 2014 MISC NSCoding is a fanta ...