2013-08-10 1 views
0

나는 사용자 signout, 나는 다음과 같은 코드 을 사용하기위한 버튼이는/_layout.cshtmlSignout 기능 나는 면도칼 와 mvc3을 사용하고

 //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/&#47;Account&#47;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 
+0

는 u는 잘못 Url.Action로 작성했습니다 ("로그온", "계정") 그것은 내가 그것을 해결 .. 그러나 행동 ValidateInput (거짓)를 사용하여 내 갱신 –

+0

감사 니틴 : 로그 아웃해야 – gs11111

+0

시도를 확인하시기 바랍니다 –

답변

1

면도기 구문을 사용하는 대신 <%@ 문자를, 그래서 이것을 사용하고 모든

$("#Logout").bind("click", function() { 
    window.location.href = '@Url.Action("LogOn", "Account")'; // assuming this is the correct action you want to use for the logout button 
}); 

또한 jQuery를에서 $("#Logout").bind$("#Logout").click로 전환 할 수 있습니다 잘 작동합니다 :

업데이트

+0

변경을했는데 다른 보안 오류가 나타납니다. 내 업데이트를 확인하십시오. – gs11111

1

왜 아약스 jquery 전화를 시도하지 마십시오

길게 보일 수도 있지만 작동해야합니다.