C# 如何使用mvc中的成员身份创建登录模块?

C# 如何使用mvc中的成员身份创建登录模块?,c#,asp.net-mvc,membership,C#,Asp.net Mvc,Membership,您好,我已经在mvc中创建了一个项目。在这个项目中,我有第一个登录模块是用简单的代码完成的。比如点击登录并检查数据库中的凭据。但现在我想更改我的代码,并使用成员身份登录模块。但在现有的项目中如何才能改变我的代码我还不知道 这是我的控制器登录方法=> [HttpPost] public ActionResult Index(UsersModel User) { if (ModelState.IsValid) { Users objUser = new

您好,我已经在mvc中创建了一个项目。在这个项目中,我有第一个登录模块是用简单的代码完成的。比如点击登录并检查数据库中的凭据。但现在我想更改我的代码,并使用成员身份登录模块。但在现有的项目中如何才能改变我的代码我还不知道

这是我的控制器登录方法=>

[HttpPost]
public ActionResult Index(UsersModel User)
{       
    if (ModelState.IsValid)
    {
        Users objUser = new Users();
        var res = objUser.Login(User.UserName, User.Password);
        if (res)
        {                        
            return RedirectToAction("Index", "Home");
        }
        else
        {                       
              ErrorMessage = "Login faild";
            ModelState.AddModelError("Error", ErrorMessage);
        }
    }
    return View();
 }
有了这段代码,我的登录做得很好。但现在我想使用会员身份登录。我这里有一个关于会员资格的问题,有什么dll吗

这是我的web.config文件=>

<?xml version="1.0" encoding="utf-8"?>
<!--
 For more information on how to configure your ASP.NET application, please 
 visit
  http://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration> 
  <connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebApplication3-20170821032922.mdf;Initial Catalog=aspnet-WebApplication3-20170821032922;Integrated Security=True"
  providerName="System.Data.SqlClient" />
  </connectionStrings>
 <appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
  <system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
 </system.web>
 <system.webServer>
   <modules>
    <remove name="FormsAuthentication" />
   </modules>
 </system.webServer>
 <runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
  </dependentAssembly>
</assemblyBinding>
 </runtime>
<system.webServer>
<handlers>
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <remove name="OPTIONSVerbHandler" />
  <remove name="TRACEVerbHandler" />
  <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
 </system.webServer>
</configuration>


任何人都知道怎么做,请告诉我

应用下面的链接,将有助于集成登录操作


您只需在Visual studio中创建一个MVC项目。在创建项目之前,请先选择身份验证类型。从那里你可以提取所有你需要的东西。@PowerStar,但在mvc中,项目已经在一年前创建了,现在我想更改登录模块,以便如何创建新项目。我想改变现有的代码,我是说你只需要创建一个独立的poc项目。从这里您可以了解mvc的成员资格。在那里你可以看到OWIN dll的身份成员身份确定我会做,然后我需要在这个项目中做相同的代码??是的,类似的