华赐软件 Bootstrap3

ASP.NET 如何判断当前请求是否是Ajax请求

 /// <summary>
        /// Description:验证用户是否登陆
        /// Author:xucixiao
        /// Date:2013-10-26
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            string lsURL = System.Configuration.ConfigurationManager.AppSettings["siteURL"];
            if (Session["user_"] == null)
            {
                if (filterContext.HttpContext.Request.IsAjaxRequest())
                {
                    filterContext.Result = new ContentResult() { Content = "-10" };
                }
                else
                {
                    filterContext.HttpContext.Response.Redirect(lsURL);
                }
            }
        }

posted @ 2013-10-26 16:50  OpenCsharp.Net  阅读(785)  评论(0编辑  收藏  举报
华赐软件 Bootstrap3
w.huacisoft.com">华赐软件 Bootstrap3