`

7.1Filter的使用

阅读更多
Filter的使用

-对Action的附加说明

Asp.net MVC中Filter
-Authorize
-HandleError
-OutputCache
-RequireHttps

AuthorizeAttribute标签
[Authorize(Roles=”Admins, SuperAdmins”)]
public class AdminController
{
//Only admins should see this.
public ActionResult Index()
{return View();}
//Only admins should see this.
public ActionResult DeleteAllUsers()
{//Thankfully, this is secured by the Authorize attribute.}}

----------------------------------------
[Authorize(Roles=”Admins, SuperAdmins”)]
public class AdminController{
//Only admins should see this.
public ActionResultIndex(){return View();}
//Only Phil should do this.
[Authorize(Users=”Phil”)]
public ActionResultDeleteAllUsers()
{
//…
}
}


Requirehttps

[RequireHttps] // Applies to this action only
public ActionResultIndex()
{
Return View();
}
[RequireHttps]
public class SampleController
{
// Will apply to all controller actions for this controller
}

OutputCache
•CacheProfile
•Duration
•Location
•NoStore   //不保存缓存
•SqlDependency //
•VaryByContentEncoding //编码格式
•VaryByCustom  //取决于调用
•VaryByHeader
•VaryByParam

[OutputCache(Duration=60, VaryByParam=”none”)]
public ActionResult About()
{
ViewData[“Title”] = “This was cached at “ + DateTime.Now;
return View();
}

<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name=”MyProfile” duration=”60” varyByParam=”none” />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
[OutputCache(CacheProfile=”MyProfile”)]
public ActionResultAbout()
{
ViewData[“Title”] = “This was cached at “ + DateTime.Now;
return View();
}

Exception Filter

[HandleError(ExceptionType= typeof(ArgumentException), View=”ArgError”)]
public ActionResultGetProduct(string name)
{
if(name == null)
{
throw new ArgumentNullException(“name”);
}
return View();
}
[HandleError(Order=1, ExceptionType=typeof(ArgumentException), View=”ArgError”)]
[HandleError(Order=2, ExceptionType=typeof(Exception)]
public ActionResult GetProduct(string name)
{…}
有顺序

2011-4-21 22:19 danny
分享到:
评论

相关推荐

    Delphi7.1 Update

    Delphi 7.1 Update Release Notes=======================================================This file contains important supplemental and late-breakinginformation that may not appear in the main ...

    gabor.zip_Gabor filter_MATLAB gabor_gabor_gabor filter matlab_ga

    gabor filter for matlab 7.1

    libusb-win32-bin-1.2.7.1.zip

    libusb-win32-bin-1.2.7.1

    11-autoinstall漏洞补丁_V7.1SP1_无月度修复包.zip

    解决autoinstall漏洞导致用户被上传后门程序的专项补丁,该补丁只适配V7.1SP1_无月度修复包

    rh-nginx114-nginx-mod-http-xslt-filter-1.14.0-3.el7.x86_64.rpm

    官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装

    视频流实时人脸检测Filter

    在win10+Windows SDK7.1+opencv2.4.13环境使用libfacedetection库对视频流中的人脸进行实时监测。

    Android实例代码

    7.1、使用简单图片:Drawable; Bitmap、BitmapFactory; 7.2、绘图:Canvas; Paint; Path; 7.3、图形特效处理:使用Matrix控制变换; 使用drawBitmapMesh扭曲图像; 使用Shader填充图形; 7.4、逐帧(Frame)动画:...

    ASP.NET.4揭秘

    16.2.1 使用controlfilter- expression进行查询545 16.2.2 使用customexpression进行查询546 16.2.3 使用dynamicfilter- expression进行查询546 16.2.4 使用methodexpression进行查询546 16.2.5 使用...

    疯狂Android讲义(第2版)源代码 第6章~第9章

    7.1、使用简单图片:Drawable; Bitmap、BitmapFactory; 7.2、绘图:Canvas; Paint; Path; 7.3、图形特效处理:使用Matrix控制变换; 使用drawBitmapMesh扭曲图像; 使用Shader填充图形; 7.4、逐帧(Frame)动画:...

    Assignment-7.1

    array.filter() array.reduce() document.createTextNode() .appendChild() 细节 可交付成果 两个单独的存储库(项目) (1)回购至少包含: main.js items.js index.html (2)回购至少包含: exercises....

    网页教程《跟姐姐学JSP》

    7. 使用filter过滤请求 7.1. 批量设置请求编码 7.2. 用filter控制用户访问权限 7.3. filter所谓的特性 7.3.1. 请求映射 7.3.2. 过滤链 7.4. filter的详细配置 8. 配置listener监听器 8.1. 使用...

    logstash-6.4.3.zip 文件sync包含mysql相关包

    output到现在(7.1)都没有jdbc的插件,然而你如果想使用output的jdbc插件就需要自己去安装热心人自己写的插件(logstash-output-jdbc),不幸的是,该作者指出没有很多的时间去维护此插件,不能保证6.3以后用户的正常...

    QPSK with matlab code and pi/4 DQPSK

    1. Overview 5 2. Simulation Setup and Block Diagram 6 2.1. Monte-Carlo Simulation Technique 6 2.2. Serial to Parallel Converter 7 ...7.1. Case-I : AWGN Channel 22 7.2. Case-II : LOS + Rayleigh Fading 23

    Android高级编程.pdf

    7.1 使用基于位置的服务 7.2 使用Test Proyider构建模拟器 7.2.1 更新模拟位置提供器中的位置 7.2.2 创建一个应用程序来管理Test Location Provider 7.3 选择——个Location Provider 7.3.1 查找可用的提供器 ...

    比DirectShow SDK的GraphEdit更强大的工具

    Directshow SDK的GraphEdit相信所有Directshow开发员都用过,但会发现它显示的Filter和Pin的信息还不是很充足,这个工具是对GraphEdit的补充,它的强大之处在于可以显示两个连接的Pin协商的MediaType类型详细信息

    Waveform Diversity: Theory & Applications

    7.1 Introduction 7.2 Majorization-Minimization 7.2 .1 卫le Landweber Iteration 7.3 Soft-Thresholding 7.3.1 Iterated Soft-Thresholding Algorithm 7.3.2 Fast ISTA (FISTA) 7.4 Nonlinear Receiver as a ...

    《Android高级编程》

    5.1.1 使用Intent来启动活动 5.1.2 使用Intent Filter来为隐式Intent提供服务 5.1.3 使用Intent Filter作为插件和扩展 5.1.4 使用Intent来广播事件 5.2 Adapter简介 5.2.1 Android提供的部分Adapter简介 5.2.2 使用...

    廖雪峰Pyhton教程3.x版[完整版]

    7.1 使用模块 114 7.2 安装第三方模块 118 8 面向对象编程 120 8.1 类和实例 122 8.2 访问限制 126 8.3 继承和多态 128 8.4 获取对象信息 134 8.5 实例属性和类属性 141 9 面向对象高级编程 143 9.1 使用__slots__ ...

Global site tag (gtag.js) - Google Analytics