當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。