Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

clear query string on PostRequestHandlerExecute

$
0
0

I wrote this code : 

 public class DenyAccessforNonAuthorizedURL : IHttpModule
    {



        public void Dispose()
        {
            //clean-up code here.
        }

        public void Init(HttpApplication context)
        {
            context.PostRequestHandlerExecute += new EventHandler(OnPreRequestHandlerExecute);

        }
        public void OnPreRequestHandlerExecute(Object sender, EventArgs e)
        {


             System.Reflection.PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection)
                                            .GetProperty("IsReadOnly", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            isreadonly.SetValue(HttpContext.Current.Request.QueryString, false, null);
            HttpContext.Current.Request.QueryString.Clear();
        }


        public void OnLogRequest(Object source, EventArgs e)
        {
            //custom logging logic can go here
        }
    }
}

Please ; Any suggestion , this must works , but it doesn't  , the url in the address bar still contains parameters , even after it has bean cleared 


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>