在WebForms的生成AntiForgeryToken [英] Generating AntiForgeryToken in WebForms

查看:191
本文介绍了在WebForms的生成AntiForgeryToken的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET Web表单网站由于需要张贴到目前坐镇WebForm的网站作为一个单独的应用程序里面我的MVC应用程序。

I have a .NET Webforms site thanks needs to post to my MVC Application which currently sits inside the Webform site as a separate application.

在网络表单应用程序需要发布一些敏感值的MVC应用程序。

The Webform application need to POST some sensitive values to the MVC Application.

有没有办法在我的WebForms应用程序生成AntiForgeryToken(),所以它可以与表单提交传递。

Is there a way to generate a AntiForgeryToken() in my WebForms Application so it can be passed with the form post.

否则没有人知道任何其他自定义防伪造code,让我做类似MVC的AntiForgeryValidation东西。

Otherwise does anyone know of any other custom anti forgery code that will allow me to do something similar to the MVC's AntiForgeryValidation.

推荐答案

自己实现它不是太难。


  • 生成一个GUID

  • 把它放在一个隐藏字段

  • 也把它在Session或Cookie的(在后一种情况下,具有一定的防篡改保护)

  • 在加工的形式进行比较的字段和存储令牌的开始。

(如果你看一下MVC的实施,很少有更给它。一些辅助方法是你所需要的。)

(If you look at the implementation of MVC, there is very little more to it. A few helper methods is all you need.)

这篇关于在WebForms的生成AntiForgeryToken的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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