English 中文(简体)
• 如何拦截和处理前的阿普文库。 净额
原标题:How to intercept and pre-process QueryStrings in Asp.Net

我们通过电子邮件向客户发放登记证。 一些电子邮件客户正在将ur改成 the。

url <url>

我认为,当用户将电子邮件转发给自己时,电子邮件客户就会重新告知原来的电子邮件(可能的话)

E.g.

https://my.app.com/login.aspx?param=var

Becomes

https://my.app.com/login.aspx?param=var%203Chttps://my.app.com/login.aspx?param=var%3E

正确生产 系统。 Web.HttpRequestValidation 例外: 一项可能危险的请求。 检测到的营养价值

在《法典》中,我是否应当拦截这些事例,并ant忙,以便用户重新被引向于 original的原始形式?

global.asax? Page_Init? HttpHandler? Pipeline?

最佳回答

在全球应用中,你可以追捕。 BeginRequest, or in the same event in an HttpModule.

<>全球>

using System;
using System.Web;

namespace MassageIncomingRequestUrl
{
    public class Global : HttpApplication
    {
        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            var app = (HttpApplication) sender;
            string path = app.Context.Request.Url.PathAndQuery;
            int pos = path.IndexOf("%20%3C");
            if (pos > -1)
            {
                path = path.Substring(0, pos);
                app.Context.RewritePath(path);
            }
        }
    }
}

<><0>

using System;
using System.Web;

namespace MassageIncomingRequestUrl
{
    public class UrlMungeModule : IHttpModule
    {
        #region IHttpModule Members

        public void Init(HttpApplication context)
        {
            context.BeginRequest += BeginRequest;
        }

        public void Dispose()
        {
            //nop
        }

        #endregion

        private static void BeginRequest(object sender, EventArgs e)
        {
            var app = (HttpApplication)sender;
            string path = app.Context.Request.Url.PathAndQuery;
            int pos = path.IndexOf("%20%3C");
            if (pos>-1)
            {
                path = path.Substring(0,pos);
                app.Context.RewritePath(path);
            }

        }
    }
}

不管你在浏览器地址中看到什么,你的请求都会得到正确的处理。 你也许能够采取额外步骤,将垃圾从据报的尿中清除出去,但这主要只是假肢。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签