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
-对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
发表评论
-
10.2Asp.net MVC各层使用TDD方式
2011-05-01 12:09 769Asp.net MVC各层使用TDD方式 Asp.net M ... -
10.1TDD简介
2011-04-30 23:09 532MVC中的测试驱动开发 为什么需要TDD TDD的由来 它 ... -
9、MVC程序安全限定
2011-04-29 22:14 1784常见网络安全攻击隐患 针对Asp.net MVC防御体系 安 ... -
8.2ASP.NET MVC2使用Ajax类库实例
2011-04-29 13:05 893ASP.NET MVC2使用Ajax类库实例 .net fo ... -
8.1Ajax类库介绍
2011-04-28 09:12 852在ASP.NET MVC中使用 -Microsoft ASP. ... -
7.2自定义开发Filter
2011-04-27 16:04 595Custom Filters ➤IAuthorization ... -
6.3Action的调用与属性
2011-04-26 09:43 640Action的调用与属性 1、唤起Action R ... -
6.2ActionResult的使用
2011-04-25 19:14 647ActionResult public abstract c ... -
6.1Controller类的基本构成
2011-04-25 09:17 640关于Controller Controller是什么? C ... -
5.6在Webform中使用routing
2011-04-23 22:48 630在Webform中使用routing 在Asp.net 4中使 ... -
5.5URL和Action匹配的秘密
2011-04-22 09:11 867Routes是如何把URL映射为Action -请求路由管道 ... -
5.4使用routing生成URL
2011-04-21 11:05 565使用routing生成URL URL生成器概述 1、质询每个 ... -
5.3使用Routes
2011-04-20 09:11 7135.3使用Routes 注册Area Route publi ... -
5.2Routes匹配URL的工作方式
2011-04-19 08:55 825URL的匹配规则 -site/{controller}/{ac ... -
5.1Url和Routes介绍
2011-04-17 12:05 6185.1Url和Routes介绍 关于Urls -域名好记好拼 ... -
4、View引擎介绍
2011-04-16 22:03 616View引擎介绍 Request =>Routing= ... -
3、HtmlHelper类(续)
2011-04-16 13:41 617HtmlHelper类(续) Html.TextArea 用 ... -
2、HtmlHelper类
2011-04-15 22:33 1069HtmlHelper类 <%Html. MVC1 & ... -
1、View层
2011-04-15 09:06 598ViewDataDictionary类 View 负责输出 ...
相关推荐
Delphi 7.1 Update Release Notes=======================================================This file contains important supplemental and late-breakinginformation that may not appear in the main ...
gabor filter for matlab 7.1
libusb-win32-bin-1.2.7.1
解决autoinstall漏洞导致用户被上传后门程序的专项补丁,该补丁只适配V7.1SP1_无月度修复包
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
在win10+Windows SDK7.1+opencv2.4.13环境使用libfacedetection库对视频流中的人脸进行实时监测。
7.1、使用简单图片:Drawable; Bitmap、BitmapFactory; 7.2、绘图:Canvas; Paint; Path; 7.3、图形特效处理:使用Matrix控制变换; 使用drawBitmapMesh扭曲图像; 使用Shader填充图形; 7.4、逐帧(Frame)动画:...
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 使用...
7.1、使用简单图片:Drawable; Bitmap、BitmapFactory; 7.2、绘图:Canvas; Paint; Path; 7.3、图形特效处理:使用Matrix控制变换; 使用drawBitmapMesh扭曲图像; 使用Shader填充图形; 7.4、逐帧(Frame)动画:...
array.filter() array.reduce() document.createTextNode() .appendChild() 细节 可交付成果 两个单独的存储库(项目) (1)回购至少包含: main.js items.js index.html (2)回购至少包含: exercises....
7. 使用filter过滤请求 7.1. 批量设置请求编码 7.2. 用filter控制用户访问权限 7.3. filter所谓的特性 7.3.1. 请求映射 7.3.2. 过滤链 7.4. filter的详细配置 8. 配置listener监听器 8.1. 使用...
output到现在(7.1)都没有jdbc的插件,然而你如果想使用output的jdbc插件就需要自己去安装热心人自己写的插件(logstash-output-jdbc),不幸的是,该作者指出没有很多的时间去维护此插件,不能保证6.3以后用户的正常...
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
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开发员都用过,但会发现它显示的Filter和Pin的信息还不是很充足,这个工具是对GraphEdit的补充,它的强大之处在于可以显示两个连接的Pin协商的MediaType类型详细信息
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 ...
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 使用...
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__ ...