AJAX timeout issue in MVC

I have an ASP.Net MVC application. I am using an AJAX request on a page which requires user authentication to fire an action on another controller, which returns a view to update a table on the page. The action that the AJAX request makes also requires authentication. The issue comes up when the user lets their session timeout and then does something to fire the AJAX request. The entire page does not redirect to the login page. Instead, the view returned to the AJAX request is the login page, which then is populated inside the div meant for the refreshed data table.

Is there a way to at least have the request return an error message instead of the login view?


当然,你可以创建你自己的Authorize属性,并检查HttpContext.Current.Request.Headers [“XMLHttpRequest”]是否返回错误消息,否则重定向到登录页面

链接地址: http://www.djcxy.com/p/71788.html

上一篇: 处理AJAX请求,如果会话已过期

下一篇: MVC中的AJAX超时问题