我的登录is..at控制器
MemberShipProvider objMProvider = new MemberShipProvider();
var abc =RedirectToAction("Index", "Home");
if (ModelState.IsValid)
{
var checkVal = objMProvider.ValidateUser(m.username, m.password);
if (checkVal == true)
{
Session["User"] = m.username;
TempData["userName"] = m.username;
//IdentityHelper.RedirectToReturnUrl("~/User_Dashboard.aspx");
abc=RedirectToAction("Dashboard","User");
}
else if (checkVal == false)
{
abc = RedirectToAction("Index", "Home");
return abc;
}
}
我的webconfig成员设置...
<system.web>
<membership defaultProvider="MemberShipProvider">
<providers>
<clear/>
<add name="MemberShipProvider" type="FndooMvc.Models.Common.MemberShipProvider"
connectionStringName="mycon"
applicationName="/" />
</providers>
</membership>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<system.webServer>
<modules>
<remove name="FormsAuthentication" />
</modules>
我的自定义成员资格提供者登录检查代码是public override bool ValidateUser(string username, string password) { return objLogin.IsValid(username,password) == true ? true : false; }
,我使用平面登录代码,然后我决定根据需要使用自定义成员资格。帮助我将此身份和原则功能与此自定义成员身份一起使用现在我想知道为什么我的request.IsAuthenicated
发布于 2015-10-13 08:37:06
看看this:
ASP.NET身份系统旨在取代以前的ASP.NET成员资格和简单的成员资格系统。它包括配置文件支持,OAuth集成,与OWIN一起工作,并包含在Visual Studio2013附带的ASP.NET模板中。
如果你想在identity and principle feature上写一篇好文章
发布于 2015-10-13 10:18:17
我需要在身份验证请求事件的全局配置中使用此代码块。
HttpCookie authCookie =Context.Request.Cookies[FormsAuthentication.FormsCookieName];
if (authCookie != null)
{
FormsAuthenticationTicket authTicket =
FormsAuthentication.Decrypt(authCookie.Value);
string[] roles = authTicket.UserData.Split(new Char[] { ',' });
GenericPrincipal userPrincipal =
new GenericPrincipal(new GenericIdentity(authTicket.Name),
roles);
Context.User = userPrincipal;
}
现在request.isAuthenticated可以工作了。
我将如何改变这个提供者,并按照Hboubati的建议使用它。
https://stackoverflow.com/questions/33094835
复制相似问题