<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>
<authenticationmode="Forms"> <formsloginUrl="~/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屬性, 重載boolAuthorizeCore(HttpContextBasehttpContext)方法,在方法中調(diào)用權(quán)限管理的接口。
分享題目:ASP.Net實(shí)現(xiàn)用戶權(quán)限管理
本文路徑:http://jinyejixie.com/article28/iejhcp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、自適應(yīng)網(wǎng)站、網(wǎng)站排名、、品牌網(wǎng)站建設(shè)、網(wǎng)站改版
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)