ASP.NET MVC 4 - ActionNameSelectorAttribute
2013-06-20 00:11
309 查看
public class MyActionNameSelectorAttribute : ActionNameSelectorAttribute
{
public override bool IsValidName(ControllerContext controllerContext, string actionName, MethodInfo methodInfo)
{
if (actionName != "Index")
{
controllerContext.HttpContext.Response.Redirect("Index");
return false;
}
return true;
}
}
public class HomeController : Controller
{
//
// GET: /Home/
[MyActionNameSelectorAttribute]
public string Index(string data )
{
return "Binggo";
}
}as you can see
when i press enter then the page is jump to the index page .aka index action
{
public override bool IsValidName(ControllerContext controllerContext, string actionName, MethodInfo methodInfo)
{
if (actionName != "Index")
{
controllerContext.HttpContext.Response.Redirect("Index");
return false;
}
return true;
}
}
public class HomeController : Controller
{
//
// GET: /Home/
[MyActionNameSelectorAttribute]
public string Index(string data )
{
return "Binggo";
}
}as you can see
when i press enter then the page is jump to the index page .aka index action
相关文章推荐
- ASP.NET MVC 4 - ActionMethodSelectorAttribute
- ASP.NET MVC 4 - ActionNameAttribute
- asp.net mvc get controller name and action name
- asp.net mvc ChildActionOnly 和ActionName的用法
- asp.net mvc ChildActionOnly 和ActionName的用法
- ASP.NET MVC 利用ActionFilterAttribute来做权限等
- asp.net MVC利用ActionFilterAttribute过滤关键字的方法
- How to get the Current Controller Name, Action, or ID in ASP.NET MVC
- ASP.NET MVC NonActionAttribute使用说明
- ASP.NET MVC ActionFilterAttribute的执行顺序
- [转]Creating an ASP.NET MVC OutputCache ActionFilterAttribute
- asp.net mvc 5 利用ActionFilterAttribute实现权限过滤
- Asp.Net MVC中不指定View Name时如何返回ActionResult的
- asp.net MVC利用ActionFilterAttribute过滤关键字的方法
- Asp.net Mvc Preview 5 体验--实现ActionSelectionAttribute来判断是否为AJAX请求而选择不同的Action
- ASP.NET MVC使用ActionFilterAttribute实现权限限制的方法(附demo源码下载)
- ASP.NET MVC 利用ActionFilterAttribute来判断用户是否登陆等等
- Asp.net mvc:使用ActionFilterAttribute记录操作日志
- ASP.NET MVC 利用ActionFilterAttribute来做权限等
- asp.net mvc ChildActionOnly 和ActionName的用法