私はかみそりでmvc3を使用しています。ユーザーをサインアウトするためのボタンがあります。次のコードshared/_layout.cshtmlを使用します
//button
<div class="button"><a href="#" id="Logout" title="Logout">
<div class="Logout"></div>Logout</a></div>
<script>
$("#Logout").bind("click", function () {
window.location.href = '@Url.Action("LogOn", "Account")';
});
</script>
accountcontroller.cs
public ActionResult Logout()
{
FormsAuthentication.SignOut();
return RedirectToAction("LogOn");
}
これにより、エラーページが表示されます
http://localhost:XXXX/%3C%=%20Url.Action(%22Logout%22,%20%22Account%22)%20%%3E
Server Error in '/' Application.
HTTP Error 400 - Bad Request.
Version Information: ASP.NET Development Server 11.0.0.0
誰かが私が間違っているところを教えてもらえますか? サインアウトの変更を行うには、ボタン クリック イベントを手伝ってください。
更新しました:
http://localhost:8436//Account/Logout
enter code here
Server Error in '/' Application.
A potentially dangerous Request.Path value was detected from the client (&).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A potentially dangerous Request.Path value was detected from the client (&).
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (&).]
System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +9673044
System.Web.ValidateRequestExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +35
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155