Accessing "Request" object properties using jquery
we are developing a web application using MVC3 and Jquery. we have a situation where we need to check the request is authenticated (@Reques开发者_开发百科t.IsAuthenticated) using Jquery. what is the best way to do that using Jquery?
Thanks.
make a helper action on one of the controllers or maybe on a Base controller and return a ContentResult
(with a value of true
or false
). Use jquery's ajax() function to perform asynchronous GET request to the server side controller action.
If you can afford to have the Javascript code inside the view then you can simply do
@if(Request.IsAuthenticated)
...do Javascript...
精彩评论