开发者

Accessing "Request" object properties using jquery

开发者 https://www.devze.com 2023-03-17 23:07 出处:网络
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 be

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...
0

精彩评论

暂无评论...
验证码 换一张
取 消