标签:mvc csr lan form string username validate result htm
在前台表单中使用@Html.AntiForgeryToken(),在后台action上添加ValidateAntiForgeryToken特性
@using (Html.BeginForm()) { @Html.AntiForgeryToken() <p> <label> Username:</label><input name="username" /></p> <p> <label> Password:</label><input name="password" type="password" /></p> <input type="submit" value="登录" /> }
[ValidateAntiForgeryToken] public ActionResult DoSth(string username, string password) { return Content("ASP.NET MVC中,表单提交防止CSRF。"); }
标签:mvc csr lan form string username validate result htm
原文地址:https://www.cnblogs.com/vichin/p/12273321.html