如何将ASP.NET身份导入ASP.NET MVC样板



我想使用Visual Studio 2013分享如何成功地将ASP.NET身份导入ASP.NET MVC样板。

我发现了很多问题,但没有确定的答案。

所以这是我想到的:

Decide on a projectsolution name
    The two projectssolutions must use the same names
    Create them in seperate directories
        ProjectsWeb<SolutionDir>
        ProjectsMVC<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_StartIdentityConfig
        App_StartStartup.Auth
        ControllersAccountController.cs
        ControllersManageController.cs
        ModelsAccountController
        ModelsIdentityModels
        ModelsAccountViewModels
        Startup.cs
        folders:
        ViewsAccount
        ViewsManage
    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

参考:

  • 将ASP.NET身份和授权控制添加到您的MVC网站
  • 尝试将身份验证添加到ASP.NET MVC样板模板

相关内容

  • 没有找到相关文章

最新更新