asp.net mvc 3 - Signout function on button click event in MVC3 in entity framework -
i'm using mvc3 razor have button signout user, use following code 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"); }
this directs me error page
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
can tell me i'm going wrong? please button click event make signout changes.
updated:
http://localhost:8436//account/logout enter code here server error in '/' application. potentially dangerous request.path value detected client (&). description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code. exception details: system.web.httpexception: potentially dangerous request.path value detected client (&). source error: unhandled exception generated during execution of current web request. information regarding origin , location of exception can identified using exception stack trace below. stack trace: [httpexception (0x80004005): potentially dangerous request.path value detected client (&).] system.web.httprequest.validateinputifrequiredbyconfig() +9673044 system.web.validaterequestexecutionstep.system.web.httpapplication.iexecutionstep.execute() +35 system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +155
the razor syntax uses , @
character instead of <%
, use , should work fine
$("#logout").bind("click", function () { window.location.href = '@url.action("logon", "account")'; // assuming correct action want use logout button });
you might want switch jquery $("#logout").bind
$("#logout").click
Comments
Post a Comment