asp.net MVC antiforgerytoken上异常RedirectToAction [英] asp.net MVC antiforgerytoken on exception RedirectToAction

查看:136
本文介绍了asp.net MVC antiforgerytoken上异常RedirectToAction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的形式实现了与AnitforgeryToken我的asp.net MVC的形式,并且还添加了属性来我的登录过程,但是当检查failes我想重定向到我的欺诈行为,而不是一个异常页面。这是可能的属性????

I have implimented the AnitforgeryToken with my asp.net MVC forms, and also added the attribute to my login procedure, however when the check failes i wish to redirect to my fraud action rather than an exception page. is this possible within the attribute ????

感谢

推荐答案

的<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.mvc.validateantiforgerytokenattribute.aspx\">ValidateAntiForgeryTokenAttribute将刚才扔<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.mvc.httpantiforgeryexception.aspx\">HttpAntiForgeryException.你可以使用HandleErrorAttribute处理这种情况:

The ValidateAntiForgeryTokenAttribute will just throw HttpAntiForgeryException. You could use the HandleErrorAttribute to handle this scenario:

[HandleError(
    ExceptionType = typeof(HttpAntiForgeryException), 
    View = "Unauthorized")]
[ValidateAntiForgeryToken]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SomeActionThatRequiresToken() 
{
    return View();
}

这篇关于asp.net MVC antiforgerytoken上异常RedirectToAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆