【发布时间】:2015-06-11 14:48:30
【问题描述】:
我在 MVC ASP.NET 应用程序中有一个 cshtml 视图。我只想让用户单击一个按钮并在执行操作之前向用户提供警告。我知道实现我想要的唯一方法是像这样使用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>
我的控制器的名称是ToolsController,我发布到的方法是ClearInviteLog。问题是,当我单击按钮时,我没有得到警告对话框,而是得到 p>
“/”应用程序中的服务器错误。 检测到来自客户端 (
堆栈跟踪: [HttpException (0x80004005): 从客户端检测到潜在危险的 Request.Path 值 (
我是 Web 开发的新手,我很困惑。我在这里做错了什么?
感谢您的宝贵时间。
【问题讨论】:
-
为你的前端使用数据绑定库而不是 Razor 来自动生成你的东西,然后你会发现你会做更少的建模,并且遇到更少的问题
-
检查这个问题,可能和你的一样stackoverflow.com/questions/5967103/…
-
我已经阅读了这个问题。它和我的“不一样”。感谢您的宝贵时间。
标签: c# asp.net-mvc razor