gpt4 book ai didi

c# - ASP.NET AjaxActionLink 请求中存在潜在危险的 Request.Path

转载 作者:太空宇宙 更新时间:2023-11-03 10:29:15 24 4
gpt4 key购买 nike

我在 MVC ASP.NET 应用程序中有一个 cshtml View 。我只想让用户单击一个按钮并在执行操作之前向用户发出警告。我知道实现我想要的唯一方法是像这样使用 AjaxActionLink

<a role="button" 
class="btn btn-lg btn-primary"
href='@Ajax.ActionLink(
"Clear Invite Log",
"ClearInviteLog",
"Tools",
null,
new AjaxOptions { HttpMethod = "GET" },
new { onclick = "return confirm('Are you sure you want to clear the invite log?');" })'>
Clear Invite Log
</a>

我的 Controller 的名称是 ToolsController,我要发布到的方法是 ClearInviteLog。问题是,当我单击按钮时,我没有看到警告对话框,而是得到了

Server Error in '/' Application. A potentially dangerous Request.Path value was detected from the client (<).

Stack Trace: [HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (<).] System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +9693412 System.Web.PipelineStepManager.ValidateHelper(HttpContext context) +53

我是网络开发的新手,我很困惑。我在这里做错了什么?

感谢您的宝贵时间。

最佳答案

你不需要设置 anchor 标签href值的Ajax.ActionLink,Ajax.ActionLink和Html.ActionLink本身作为 anchor 标签渲染,你只需要直接使用Ajax.ActilnLink:

@Ajax.ActionLink(
"Clear Invite Log",
"ClearInviteLog",
"Tools",
null,
new AjaxOptions { HttpMethod = "GET" },
new
{
onclick = "return confirm('Are you sure you want to clear the invite log?');",
@class ="btn btn-lg btn-primary",
role="button" })

关于c# - ASP.NET AjaxActionLink 请求中存在潜在危险的 Request.Path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30784140/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com