我正在制作一个简单的网站,列出某个文件夹中的文件.如果用户具有管理员权限,则用户可以通过单击"删除"按钮来删除文件.
在我的.aspx文件中,我有以下代码:
<asp:Button runat="server" Text="Delete" OnCommand="FileList_Delete"
CommandArgument='<%#Eval("FilePath")%>' Visible='<%CurrentUserIsAdmin()%>' />
Run Code Online (Sandbox Code Playgroud)
因此,如果CurrentUserIsAdmin()返回则不会呈现按钮false.
该按钮呈现如下:
<input type="submit" name="ctl00$ctl00$MainContent$LocalMainContent$FileList$ctrl0$ctl17" value="Delete" />
Run Code Online (Sandbox Code Playgroud)
我的问题是:如果用户修改网页客户端旨在点击这个隐形按钮,我能否确定这种方法对于已知代码攻击是安全的?或者我是否必须在代码隐藏中采取预防措施并在按钮单击事件中验证用户的权利?