1. Adding a custom header to the response:
<script>
public ActionResult Index(){
if (!HttpContext.User.Identity.IsAuthenticated)
{
HttpContext.Response.AddHeader("REQUIRES_AUTH","1");
}
return View()
}
</script>
2. Binding a JavaScript function to the ajaxSuccess event and checking to see if the header exists:
<script>
jQuery('body').bind('ajaxSuccess',function(event,request,settings){
if (request.getResponseHeader('REQUIRES_AUTH') === '1'){
window.location = '/';
};
});
</script>
SOURCE: stackoverflow.com
<script>
public ActionResult Index(){
if (!HttpContext.User.Identity.IsAuthenticated)
{
HttpContext.Response.AddHeader("REQUIRES_AUTH","1");
}
return View()
}
</script>
2. Binding a JavaScript function to the ajaxSuccess event and checking to see if the header exists:
<script>
jQuery('body').bind('ajaxSuccess',function(event,request,settings){
if (request.getResponseHeader('REQUIRES_AUTH') === '1'){
window.location = '/';
};
});
</script>
SOURCE: stackoverflow.com
This comment has been removed by a blog administrator.
ReplyDelete