我想分享如何使用Visual Studio 2013将ASP.NET身份成功导入ASP.NET MVC Boilerplate。
答案 0 :(得分:0)
我发现了很多问题,但没有明确的答案。
所以这就是我提出的:
Decide on a project\solution name
The two projects\solutions must use the same names
Create them in seperate directories
Projects\Web\<SolutionDir>
Projects\MVC\<SolutionDir>
Create project from template - ASP.NET Web Application
Select a template - MVC
Rebuild Solution
Close Solution
Create project from template - ASP.NET MVC Boilerplate
Right-click Project
Properties
Make sure Assembly name and Default namespace is the same
Rebuild Solution
There may be some missing namespaces
Double-click the build errors to open effected code
ReSharper can help automatically regenerate the missing namespaces
Right-click References
Manage Nuget Packages
Install packages:
Microsoft.Owin.Host.SystemWeb
Microsoft.AspNet.Identity.Core
Microsoft.AspNet.Identity.OWIN
Microsoft.AspNet.Identity.EntityFramework
Microsoft.Owin.Security.Google
Copy the following files and folder structure from ASP.NET Web project into ASP.NET MVC project:
files:
App_Start\IdentityConfig
App_Start\Startup.Auth
Controllers\AccountController.cs
Controllers\ManageController.cs
Models\AccountController
Models\IdentityModels
Models\AccountViewModels
Startup.cs
folders:
Views\Account
Views\Manage
Insert the following into Configuration method of Start.cs:
ConfigureAuth(app);
Find following section in Web.config from ASP.NET Web project and copy into Web.config in ASP.NET MVC project:
<connectionStrings>
<add
name="DefaultConnection"
connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\..."
providerName="System.Data.SqlClient" />
</connectionStrings>
Rebuild Solution
参考文献: