2017-08-21 7 views
1

こんにちは私はmvc C#で1つのプロジェクトを作成しています。このプロジェクトでは、私は最初のログインモジュールが単純なcode.likeで行われてログインをクリックし、データベースのcredenatialをチェックします。しかし今、私は自分のコードを変更し、メンバーシップを使ってログインモジュールをやりたいのです。しかし、既存のプロジェクトで私のコードを変更する方法は私には分かりません。mvc C#のメンバーシップを使用してログインモジュールを作成するには?

これは私が非常によく、ログインを行っている使用して、このコードを使用してログインのための私のコントローラメソッド=>

[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(); 
} 

です。今はメンバーシップを使ってログインしたい。私はメンバーシップのためにここで1つの質問を持って任意の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> 

いずれかを私に教えてくださいことを行うことができますどのようにアイデアを持っています。

+0

あなただけのVisual StudioでMVCプロジェクトを作成します。プロジェクトを作成する前に認証タイプを選択します。そこから、必要なものすべてを抽出することができます。 –

+0

@ PowerStarしかし、mvcプロジェクトはすでに1年前に作成されています。私はログインモジュールを変更したいので、どのように新しいプロジェクトを作成できますか?私は既存のコードを変更したい – Edit

+0

私は、単なるスタンドアロンのpocプロジェクトを作成すると言っています。そこからmvcのメンバーシップを理解できます。 OWINのIDメンバシップのためのDLLが表示されます。 –

答えて

関連する問題