Exemplo n.º 1
0
        private void OnBeginRequest(object sender, EventArgs args)
        {
            HttpContext context = HttpContext.Current;
            string      query   = context.Request.RawUrl;

            const string QParamName = "QPARAM";

            if (context.Request.Url.OriginalString.Contains(".aspx") && query.Contains("?") && context.Request.Cookies.AllKeys.Contains(".ASPXAUTH"))
            {
                var param = query.Split(new char[] { '?' }, 2);
                if (param.Length == 2)
                {
                    if (query.Contains(QParamName))
                    {
                        var encrypted = context.Request.QueryString[QParamName];
                        context.RewritePath(param[0], string.Empty, SecurityModelCrypto.Decrypt(encrypted));
                    }
                    else if (0 == string.Compare(context.Request.HttpMethod, "GET", true))
                    {
                        string newUrl = string.Format("{0}?{1}={2}", param[0], QParamName, SecurityModelCrypto.Encrypt(param[1]));
                        context.Response.Redirect(newUrl);
                    }
                }
            }
        }