问题描述
我是CSRF的新手,我一直试图让CSRF在我的ASP.NET Web窗体应用程序中工作。我已经在aspx页面(Main.aspx)的form标签中实现了这一行代码:
<%= System.Web.Helpers.AntiForgery.GetHtml() %>
以及此代码在Page_Load(...)事件中相应的aspx.cs页(Main.aspx.cs)中:
if (IsPostBack)
AntiForgery.Validate();
这有效-或至少在调用我的页面时不会引发任何错误(首先执行Main,然后执行SomePage)。我现在正尝试在ascx页的相同位置(SomePage.ascx和SomePage.ascx.cs)中另外实现相同的逻辑,但是在Main.aspx.cs中得到以下错误:
The anti-forgery token Could not be decrypted. If this application is hosted by a Web Farm or cluster,ensure that all machines are running the same version of ASP.NET Web Pages and that the configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.
可以在ascx / ascx.cs页面中实现CSRF吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)