我昨天安装了Visual Studio 2012(RTM,通过mytt DreamSpark帐户),并创建了一个演示MVC站点(使用.NET 4.0,因为我希望它在Azure上受支持)。ASP.NET 4 Membeship架构已更改
我已经开始调查该项目,除了使用外部服务(Facebook,Twitter,Windows Live和Google)的内置选项外,我发现整个会员模式已被更改:
新结构包含4个表(UserProfile是第一个代码接近实体框架表)。 请注意,虽然表前缀是“webpages_”,但它是一个适当的MVC 4站点。
我已经打开了AccountModels.cs文件,发现它已被更改过:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
namespace MyGuestbook.Models
{
public class UsersContext : DbContext
{
public UsersContext()
: base("DefaultConnection")
{
}
public DbSet<UserProfile> UserProfiles { get; set; }
}
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
}
public class RegisterExternalLoginModel
{
[Required]
[Display(Name = "User name")]
public string UserName { get; set; }
public string ExternalLoginData { get; set; }
}
public class LocalPasswordModel
{
[Required]
[DataType(DataType.Password)]
[Display(Name = "Current password")]
public string OldPassword { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm new password")]
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
public class LoginModel
{
[Required]
[Display(Name = "User name")]
public string UserName { get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[Display(Name = "Remember me?")]
public bool RememberMe { get; set; }
}
public class RegisterModel
{
[Required]
[Display(Name = "User name")]
public string UserName { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
public class ExternalLogin
{
public string Provider { get; set; }
public string ProviderDisplayName { get; set; }
public string ProviderUserId { get; set; }
}
}
所以我想问: - 这是否新的用户结构(即由asp_regsql产生.exe)或者这是一个特定于模板的结构? - 有人有关于新结构的文档以及如何与其结合? - 有人知道如何将旧结构的“旧”项目(例如MVC 3项目)迁移到新结构?
谢谢! :)
请在此处总结或引用关键位。链接腐烂发生,渲染链接只回答完全无用。 –
上面的链接总结了传统ASP.NET方案与ASP.NET MVC 4使用的新方案和项目模板之间的区别。我的问题的答案是文章内容......没有具体的答案整个问题。 –