我必须在单击按钮时重定向到控制器操作,但出现此错误
`A potentially dangerous Request.Path value was detected from the client (&).`
这是我的代码:
视图/_Layout.cshtml
<body>
<div id="wrapper">
<div id="tab1">
<div class="tab2">
<div id="test2" class="officebar">
<ul>
<li class="current"><a href="#" rel="home">Main</a>
<ul>
// ..other button code..
<li><span>Logout</span>
<div class="button">
<a href="#" id="Logout" title="Logout">
<div class="logout">
</div>
Logout</a>
</div>
</li></ul></li>
<script>
$("#Logout").click("click", function () {
//window.refresh("./Account/Logoutview");
// "@Url.Action("Logoutview", "Account")";
window.location = "@Url.Action("Logoutview", "Account")";
window.location.href = "@Url.Action("Logoutview", "Account")";
});
</script>
这是我的注销视图位置:
Views/Account/Logoutview
这是我的输出错误,请帮助:
编辑3:
如果我使用,我可以点击操作方法
<li>
<div><a class="button" href="@Url.Action("Logoutview", "Account")" title="Logout">Logout</a>
</div></li>
但我需要使用上面提到的设计。这就是问题所在。
解决方案:我尝试 window.location.href = 'Account/Logoutview';
代替 window.location.href = "@Url.Action("Logoutview", "Account")";
谢谢您 user2110309,PKKG,MMohamad Bataineh 为您提供时间:)