代码之家  ›  专栏  ›  技术社区  ›  LP13

在owin管道中如何删除querystring参数?

  •  0
  • LP13  · 技术社区  · 7 年前

    我正试图从owin请求中删除某些querystring参数,但它不起作用。

    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.UseOwinCookieSaver();
    
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                // removed for brevity
            });
    
            app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
            {
                // removed for brevity
    
                Notifications = new OpenIdConnectAuthenticationNotifications
                {
                    RedirectToIdentityProvider = (context) =>
                    {
                        if (context.ProtocolMessage.RequestType == OpenIdConnectRequestType.AuthenticationRequest)
                        {   
                           //here i am trying to remove querystring `q=abcd`
                            request.QueryString = new QueryString(WebUtility.UrlEncode(WebUtility.UrlDecode(request.QueryString.ToString()).Replace("q=abcd", "")));
                        }
    
    
                        return Task.FromResult(0);
                    }
                }
            });
       }
    

    }

    验证后,当请求返回时,url仍然显示查询字符串 q=abcd

    0 回复  |  直到 7 年前
    推荐文章