English 中文(简体)
asp.net consecutive are backslashes removed from url
原标题:

I m having an issue in my ASP.NET web app where intentionally consecutive backslashes are being removed from the request url.

I ll request something like: localhost/Page/A//C

But when the request hits the page, the raw url is: localhost/Page/A/C

Not sure if this is the culprit, but I do have a Url Rewite regex in place, here s the rule:

   <system.webServer>
        <rewrite>
            <rules>
                <rule name="Games QueryString">
                  <match url="^(Page|OtherPage).aspx(?:/([w-_()]+)(?:/([w-_() ]*)(?:/([w-_()]+))?)?)?$" />
                  <action type="Rewrite" url="{R:1}.aspx?1={R:2}&amp;2={R:3}&amp;3={R:4}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>

So, after the rewrite, the querystring is coming out as Page.aspx?1=A&2=C&3= When it should be Page.aspx?1=A&2=&3=C

Help please!!

问题回答

You could probably change your regex to something like this:

^(Page|OtherPage).aspx(?:/+([w-_()]+)(?:/+([w-_() ]*)(?:/+([w-_()]+))?)?)?$

I have added a "+" after your matches to "/", which changes them from accepting a single "/" to accepting one or more.

Also, I cannot work out for the life of my why you d want to have extra slashes in there. Probably a bad idea. Reconsider doing that for any reason.





相关问题
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!

热门标签