Dis*_*ive 8 c# asp.net viewstate webforms
This is in ASP.NET web forms, I have a save button on a screen. When I load the page initially, under certain conditions, the save button is not rendered.
button1.visible = false
Run Code Online (Sandbox Code Playgroud)
In my button clicked event, I have this
public void button1_click(Object sender, EventArgs e)
{
SaveData();
}
Run Code Online (Sandbox Code Playgroud)
The only security preventing the user being from being saved is on whether the save button is rendered.
In MVC, it would be trivial to access the save button action method just by making a HTTP POST to the server with my own modified request.
在ASP.NET Web表单中,我有点困惑,因为它依赖于被回发的加密ViewState.我是否仍需要将此安全性添加到button1_click事件中?如果是这样,那么你能告诉我一个客户端如何能够在没有按钮可见的情况下触发到达按钮点击事件的服务器回发吗?
这是关于 ViewState 的常见错误之一 - 它不服务于您的点击事件和许多其他事情。
每次单击按钮(或复选框,如果启用了自动回发)都会引发一个提交到服务器的表单。有关单击内容的所有信息都以纯文本形式包含在表单回发数据中。然后服务器解析这些数据,并且当您的按钮实现了 IPostBackDataHandler 时,它会引发适当的事件,例如“按钮 id 已被单击”。因此,您实际上可以更改请求正文:
D__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPD...&ctl00%24_pdContent%24txtEmail=qwe%40aeqw.ry&ctl00%24_pdContent%24btnRtnUser=Login&__EVENTVALIDATION=%2FwEWDAL424aUAQLjtYbqCAKu8qTUCQLXm%2BfNAwKk2O%2B4DgK3ypStCAL6q%2BaACgKBnvb9CQLr8ey6CALxoZvDCALFt96ABgLMorjMAwoW3zW69NNlOXygWNnB6luGVWnk
Run Code Online (Sandbox Code Playgroud)
在上面您可以看到 id=ctl00__pdContent_txtEmail 的输入内容,并单击 id=ctl00__pdContent_btnRtnUser 的登录按钮。
有关 WebForms 中服务器事件的更多说明请参见此处。
请在此处阅读有关 ViewState 的更多信息,或者在此处阅读更好的解释。
| 归档时间: |
|
| 查看次数: |
262 次 |
| 最近记录: |