URL编码处理之前丢失 - ASP.net [英] URL Encoding being lost before processing - ASP.net

查看:137
本文介绍了URL编码处理之前丢失 - ASP.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个网上商店,使用URL编码广泛。

I am building a web-store that uses URL encoding extensively.

我有部门及放大器的列表;分类在我的数据库,我用它来生成的链接。这些,当然,URL连接codeD之前它们被发送。

I have a list of Departments & Categories in my database which I use to generate the links. These are, of course, URL encoded before they are sent.

一些典型的链接是...

      的 /MySite/Store/Countertop+Equipment/Can+Openers.aspx

      的 /MySite/Store/Dinnerware.aspx
      的 /MySite/Store/Kitchen/Pastry%2f+Decorating.aspx

Some Typical Links are...
/MySite/Store/Countertop+Equipment/Can+Openers.aspx
/MySite/Store/Dinnerware.aspx /MySite/Store/Kitchen/Pastry%2f+Decorating.aspx

在我的HttpHandler我打电话app.Request.Path获得当前路径。此调用返回的字符串不再URL连接这使它不可能对我来说,正确地分析codeD。
一旦URL编码丢失

/MySite/Store/Kitchen/Pastry%2f+Decorating.aspx 的变

/MySite/Store/Kitchen/Pastry/Decorating.aspx 的。

In my HTTPHandler I call app.Request.Path to obtain the current path. The string returned by this call is no longer URL encoded which is making it impossible for me to parse correctly. Once the URL encoding is lost
/MySite/Store/Kitchen/Pastry%2f+Decorating.aspx becomes
/MySite/Store/Kitchen/Pastry/Decorating.aspx.

这显然打破了该URL转换为查询字符串的方法。

This is obviously breaking the method that converts the URL to a QueryString.

任何人都知道如何解决这个问题?

Anyone know how to fix this?

下面是核心我的HttpHandler

Here is the core of my HTTPHandler

public void Init(System.Web.HttpApplication app)
{
    app.BeginRequest += new EventHandler(Application_BeginRequest);
}

private void Application_BeginRequest(object sender, EventArgs e)
{
    System.Web.HttpApplication app = (System.Web.HttpApplication)sender;

    string realUrl = GetRealUrl(app.Request.Path);

    if (!String.IsNullOrEmpty(realUrl))
        app.Context.RewritePath(realUrl, false);
}

我真的AP preciate您的帮助!

I really appreciate your help!

推荐答案

原来,这个问题在IIS中发生的.Net甚至会在要求其手中之前。看来,这是一个死胡同。

It turns out that the issue is occurring in IIS before .Net even gets its hands on the request. It appears that this is a dead end.

警告的另一个词是我的IIS测试服务器(XP)被拒绝含卫浴codeD amperstands作为安全风险的要求,不能被说服任何东西短注册表编辑进行合作。不知道这是否也适用于所有版本,但即使一台服务器变量可以被检索,这似乎是另一个很好的理由来使用不同的战术。

An additional word of warning is that my IIS test server (XP) was rejecting requests containing encoded amperstands as a security risk and could not be persuaded to cooperate with anything short of a registry edit. Not sure if this goes for all versions, but even if a server variable can be retrieved this seems like another good reason to use a different tactic.

下面是接受的解决方案的后续问题 -

Here is the follow-up question with the accepted solution-

<一个href=\"http://stackoverflow.com/questions/1288630/asp-net-url-encoding\">http://stackoverflow.com/questions/1288630/asp-net-url-encoding

这篇关于URL编码处理之前丢失 - ASP.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆