日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

淺析ASP.NET MVC :MVC頁面驗(yàn)證與授權(quán)(2)_.Net教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:解析.NET Framework 新功能和增強(qiáng)的功能
ASP.NET 移動(dòng)控件(原來為 Microsoft Mobile Internet Toolkit)擴(kuò)展了 .NET Framework 和 Visual Studio .NET,提供了對移動(dòng)電話和個(gè)人數(shù)據(jù)助理 (PDA) 等移動(dòng)(無線)設(shè)備的支持。.NET Framew

自定義了兩個(gè)自定義Attribute,分別為:RequiresAuthenticationAttribute和RequiresRoleAttribute。通過這兩個(gè)Attribute來可以作用于Class和Method,用標(biāo)記哪些Controller或Action需要登錄后,或者需要擁有哪些角色才能執(zhí)行。如果用戶沒有擁有訪問當(dāng)然Controller或Action權(quán)限的時(shí)候,就會(huì)自動(dòng)被重定向到登錄頁面去。下面是兩個(gè)類的定義:

以下為引用的內(nèi)容:
/// <summary>
/// Checks the User's authentication using FormsAuthentication
/// and redirects to the Login Url for the application on fail
/// </summary>
[RequiresAuthentication]
public class RequiresAuthenticationAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//redirect if not authenticated
if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
{
//use the current url for the redirect
string redirectOnSuccess = filterContext.HttpContext.Request.Url.AbsolutePath;
//send them off to the login page
string redirectUrl = string.Format("?ReturnUrl={0}", redirectOnSuccess);
string loginUrl = FormsAuthentication.LoginUrl redirectUrl;
filterContext.HttpContext.Response.Redirect(loginUrl, true);
}
}
}

分享:.NET教程之ASP.NET緩存方法分析和實(shí)踐示例
盡早緩存;經(jīng)常緩存 您應(yīng)該在應(yīng)用程序的每一層都實(shí)現(xiàn)緩存。向數(shù)據(jù)層、業(yè)務(wù)邏輯層、UI 或輸出層添加緩存支持。內(nèi)存現(xiàn)在非常便宜 — 因此,通過以智能的方式在整個(gè)應(yīng)用程序中實(shí)現(xiàn)緩存,

共2頁上一頁12下一頁
來源:模板無憂//所屬分類:.Net教程/更新時(shí)間:2009-09-09
相關(guān).Net教程