当前位置: 首页>>代码示例>>C#>>正文


C# HttpRequestBase.IsAjaxRequest方法代码示例

本文整理汇总了C#中System.Web.HttpRequestBase.IsAjaxRequest方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestBase.IsAjaxRequest方法的具体用法?C# HttpRequestBase.IsAjaxRequest怎么用?C# HttpRequestBase.IsAjaxRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpRequestBase的用法示例。


在下文中一共展示了HttpRequestBase.IsAjaxRequest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckForAuthorizationFailure

 /// <summary>
 /// Checks for authorization failure and if result of ajax call overrides asp.net redirect to return a 401.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="response">The response.</param>
 /// <param name="context">The context.</param>
 internal void CheckForAuthorizationFailure(HttpRequestBase request, HttpResponseBase response, HttpContextBase context)
 {
     if (!request.IsAjaxRequest() || !true.Equals(context.Items["RequestWasNotAuthorized"])) return;
     response.StatusCode = 401;
     response.ClearContent();
     var content = new {title = HttpContext.GetGlobalResourceObject("Session", "Title.SessionHasExpired"), content = HttpContext.GetGlobalResourceObject("Session", "Messsage.SessionHasExpired")};
     var serializer = new JavaScriptSerializer();
     response.Write(serializer.Serialize(content));
 }
开发者ID:ricardo100671,项目名称:Avantech.Common,代码行数:15,代码来源:AjaxAuthorizationModule.cs

示例2: CheckForAuthFailure

 internal void CheckForAuthFailure(HttpRequestBase request, HttpResponseBase response, HttpContextBase context)
 {
     //NOTE: This will change *all* 302's for AJAX requests to 401s.  That could cause problems, but it will
     //		work for now.
     if (response.StatusCode == 302 && request.IsAjaxRequest())
     {
         response.StatusCode = 401;
         response.ClearContent();
     }
 }
开发者ID:rajeshpillai,项目名称:Fail-Tracker,代码行数:10,代码来源:AjaxAuthorizationModule.cs

示例3: TrataErro


//.........这里部分代码省略.........
                    erroRepository = new ErroRepository();

                    erro = new Erro();

                    erro.Pagina = HttpContext.Current.Request.Url.ToString();
                    erro.PaginaAnterior = urlreferrer.ToString();
                    erro.RequestHost = HttpContext.Current.Request.UserHostAddress.ToString();
                    erro.HostName = HttpContext.Current.Request.UserHostName.ToString();
                    erro.UserAgent = HttpContext.Current.Request.UserAgent.ToString();
                    erro.InfoUsuario = infoUsuario.ToString();
                    erro.ErroMsg = mensagem.ToString();

                    erroRepository.Add(erro);
                    erroRepository.Save();

                    gravouErro = "<font color='blue'>Sim (Erro #" + erro.Id + ")</font>";
                }
                catch (Exception e)
                {
                    gravouErro = "<p><font color='red'>Ocorreu um erro ao tentar gravar o erro no banco.</font></p>";
                    gravouErro = "<fieldset><legend>Detalhes do Erro</legend>";

                    cont = 1;
                    while (e != null)
                    {
                        gravouErro += "<fieldset><p><strong>Erro:</strong></p>";
                        gravouErro += "<p>" + e.Message + "</p>";
                        gravouErro += "<p><strong>Stack Trace:</strong></p>";
                        gravouErro += "<p>" + e.StackTrace + "</p>";

                        String method = "";

                        if (e.TargetSite != null)
                        {
                            gravouErro = e.TargetSite.Name;
                        }

                        gravouErro += "<p><strong>Method:</strong></p>";
                        gravouErro += "<p>" + method + "</p>";
                        gravouErro += "<p><strong>Source:</strong></p>";
                        gravouErro += "<p>" + e.Source + "</p>";

                        e = e.InnerException;
                        cont++;
                    }
                    for (int i = 1; i <= cont; i++)
                    {
                        mensagem += "</fieldset>";
                    }
                    gravouErro = "</fieldset>";
                }

                #endregion

                if (enviarEmail)
                {
                    String body = Util.Email.GetCorpoEmail("erro");

                    body = body
                        .Replace("[data]", Util.Data.Formata(DateTime.Now, Util.Data.FormatoData.Completo))
                        .Replace("[pagina]", HttpContext.Current.Request.Url.ToString())
                        .Replace("[pagina_anterior]", urlreferrer)
                        .Replace("[request_host]", HttpContext.Current.Request.UserHostAddress.ToString())
                        .Replace("[host_name]", HttpContext.Current.Request.UserHostName.ToString())
                        .Replace("[user_agent]", HttpContext.Current.Request.UserAgent.ToString())
                        .Replace("[requisicao_ajax]", (Request != null) ? (Request.IsAjaxRequest()) ? "Sim" : "Não" : " - ")
                        .Replace("[info_usuario]", infoUsuario)
                        .Replace("[gravou_erro]", gravouErro)
                        .Replace("[erro_msg]", mensagem);

                    try
                    {
                        Util.Email.Enviar(Util.Email.EmailEnvioPadrao, Util.Email.EmailDesenvolvedor, body, "Ocorreu algum erro");

                        if (erro != null)
                        {
                            erro.EnviouEmail = true;

                            erroRepository.Save();
                        }
                    }
                    catch
                    {
                        if (erro != null)
                        {
                            erro.EnviouEmail = false;

                            erroRepository.Save();
                        }
                    }
                }
                else
                {
                    erro.EnviouEmail = false;

                    erroRepository.Save();
                }

                #endregion
            }
开发者ID:salez,项目名称:Guirotab,代码行数:101,代码来源:Sistema.cs

示例4: GetActionResultTypeByRequest

 /// <summary>
 /// 
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public static ActionResultType GetActionResultTypeByRequest(HttpRequestBase request)
 {
     string resulttype = request["resulttype"] ?? string.Empty;
     if (request.IsAjaxRequest() || string.Equals(resulttype, ActionResultType.Json.ToString(), StringComparison.OrdinalIgnoreCase))
         return ActionResultType.Json;
     else
         return ActionResultType.Normal;
 }
开发者ID:ritacc,项目名称:RitaccTest,代码行数:13,代码来源:MessageHelper.cs

示例5: WriteJsonResponse

 private bool WriteJsonResponse(HttpRequestBase request, HttpResponseBase response, string json)
 {
     if (request.IsAjaxRequest())
     {
         response.Status = Constants.HttpSuccess;
         response.ContentType = Constants.JsonContentType;
         response.Write(json);
         return true;
     }
     return false;
 }
开发者ID:bevacqua,项目名称:Swarm,代码行数:11,代码来源:HttpApplicationErrorHander.cs


注:本文中的System.Web.HttpRequestBase.IsAjaxRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。