您好,登錄后才能下訂單哦!
<membership defaultProvider="CustomMembershipProvider"> <providers> <clear /> <add name="CustomMembershipProvider" type="UIH.PACS.AuthorizationUtility.CustomMembershipProvider" connectionStringName="uihrisdbEntities" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" description="Stores and retrieves membership data from the local Microsoft SQL Server database" /> </providers> </membership>
<authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" defaultUrl="~/PatientAdmin/Index" timeout="2880" /> </authentication>
3.LogOn方法中的使用
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return Redirect(returnUrl); } else { FormsAuthentication.RedirectFromLoginPage(model.UserName, false); //return RedirectToAction("Index", "PatientAdmin"); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } // If we got this far, something failed, redisplay form return View(model); }
4.繼承AuthorizeAttribute屬性, 重載bool AuthorizeCore(HttpContextBase httpContext)方法,在方法中調用權限管理的接口。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。