您的位置:首页 > 编程语言 > ASP

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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: