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

时间:2018-11-16 23:15:10

标签: asp.net-mvc owin owin-middleware request.querystring

我正在尝试从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 个答案:

没有答案