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


C# HttpContextBase.IsAjaxRequest方法代码示例

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


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

示例1: GetLoginUrl

 public override string GetLoginUrl(HttpContextBase context)
 {
     var culture = CultureInfo.CurrentCulture.Name.ToLowerInvariant();
     var builder = new StringBuilder();
     builder.Append("https://www.facebook.com/dialog/oauth");
     builder.Append("?response_type=token");
     builder.AppendFormat("&redirect_uri={0}", WebUtility.UrlEncode(string.Format("https://{0}/", context.Request.Headers["HOST"])));
     builder.AppendFormat("&client_id={0}", "");
     builder.AppendFormat("&scope={0}", "email");
     builder.AppendFormat("&state={0}", WebUtility.UrlEncode(context.IsAjaxRequest() ? string.Format("/{0}{1}", culture, context.Request.Url.Query) : context.Request.Url.PathAndQuery));
     return builder.ToString();
 }
开发者ID:davidlai-msft,项目名称:SimpleWAWS,代码行数:12,代码来源:TwitterAuthProvider.cs

示例2: GetLoginUrl

 public override string GetLoginUrl(HttpContextBase context)
 {
     var culture = CultureInfo.CurrentCulture.Name.ToLowerInvariant();
     var builder = new StringBuilder();
     builder.Append("https://oauth.vk.com/authorize");
     builder.AppendFormat("?client_id={0}", AuthSettings.VkClientId);
     builder.Append("&scope=email");
     builder.AppendFormat("&redirect_uri={0}", WebUtility.UrlEncode(string.Format("https://{0}/", context.Request.Headers["HOST"])));
     builder.Append("&response_type=code");
     builder.Append("&v=5.35");
     // Vk.com UrlDecode the state query before passing it back to us. This is different from how AAD, Google and Facebook do it.
     // Hence the double encoding below to work around that issue.
     builder.AppendFormat("&state={0}", WebUtility.UrlEncode(WebUtility.UrlEncode(context.IsAjaxRequest() ? string.Format("/{0}{1}", culture, context.Request.Url.Query) : context.Request.Url.PathAndQuery)));
     return builder.ToString();
 }
开发者ID:davidlai-msft,项目名称:SimpleWAWS,代码行数:15,代码来源:VkAuthProvider.cs

示例3: GetLoginUrl

 public override string GetLoginUrl(HttpContextBase context)
 {
     var culture = CultureInfo.CurrentCulture.Name.ToLowerInvariant();
     var builder = new StringBuilder();
     builder.Append(AuthSettings.BaseLoginUrl);
     builder.Append("?response_type=id_token");
     builder.AppendFormat("&redirect_uri={0}", WebUtility.UrlEncode(string.Format("https://{0}/", context.Request.Headers["HOST"])));
     builder.AppendFormat("&client_id={0}", AuthSettings.AADAppId);
     builder.Append("&response_mode=query");
     builder.AppendFormat("&resource={0}", WebUtility.UrlEncode("https://management.core.windows.net/"));
     builder.AppendFormat("&site_id={0}", "500879");
     builder.AppendFormat("&nonce={0}", Guid.NewGuid());
     builder.AppendFormat("&state={0}", WebUtility.UrlEncode(context.IsAjaxRequest() ? string.Format("/{0}{1}", culture, context.Request.Url.Query) : context.Request.Url.PathAndQuery));
     return builder.ToString();
 }
开发者ID:davidlai-msft,项目名称:SimpleWAWS,代码行数:15,代码来源:AADProvider.cs

示例4: PostReleaseRequestState

        private static void PostReleaseRequestState(HttpContextBase context)
        {
            if (RequestIsWebResource(context))
                return;

            var builder = context.ClientResources();

            if(context.IsAjaxRequest())
            {
                if(context.IsPartialRenderingRequest())
                    context.Response.Filter = new ClientResourcesPartialViewResponseFilter(context.Response.Filter, context, builder);
            }
            else
                context.Response.Filter = new ClientResourcesResponseFilter(context.Response.Filter, context, builder);

            context.Trace.Write("ClientResourceManager", "Injected client resources into response");
        }
开发者ID:jchadwick,项目名称:ClientResourceManager,代码行数:17,代码来源:Module.cs

示例5: AuthenticateRequest

 protected void AuthenticateRequest(HttpContextBase context, Func<HttpContextBase, TokenResults> providerSpecificAuthMethod)
 {
     try
     {
         switch (providerSpecificAuthMethod(context))
         {
             case TokenResults.DoesntExist:
                 if (context.IsAjaxRequest())
                 {
                     context.Response.Headers["LoginUrl"] = GetLoginUrl(context);
                     context.Response.StatusCode = 403; // Forbidden
                 }
                 else
                 {
                     context.Response.RedirectLocation = GetLoginUrl(context);
                     context.Response.StatusCode = 302; // Redirect
                 }
                 break;
             case TokenResults.ExistAndWrong:
                 // Ajax can never send an invalid Bearer token
                 context.Response.RedirectLocation = AuthSettings.LoginErrorPage;
                 context.Response.StatusCode = 302; // Redirect
                 break;
             case TokenResults.ExistsAndCorrect:
                 // Ajax can never send Bearer token
                 context.Response.Cookies.Add(CreateSessionCookie(context.User));
                 context.Response.RedirectLocation = context.Request["state"];
                 context.Response.StatusCode = 302; // Redirect
                 break;
             default:
                 //this should never happen
                 break;
         }
     }
     catch (Exception e)
     {
         SimpleTrace.Diagnostics.Error(e, "General Authentication Exception");
         context.Response.RedirectLocation = AuthSettings.LoginErrorPage;
         context.Response.StatusCode = 302; // Redirect
     }
     finally
     {
         context.Response.End();
     }
 }
开发者ID:davidlai-msft,项目名称:SimpleWAWS,代码行数:45,代码来源:BaseAuthProvider.cs


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