English 中文(简体)
URLEncoding an Array of URLs NET
原标题:URLEncoding an Array of URLs .NET

我有一阵列,有URLs,如<编码>http://www.example.com?a=1&b=2&c=3,我需要每个URL Encodes。

但是,如果我使用<条码>的话。 缩略语

Is there anyway to achieve this?

此外,参数值不仅可能具有空间,而且可能具有“安乐”的标志。

问题回答

由于大家的回答,你帮助我找到我可以使用的解决办法。

        Dim sURL As String = "http://www.example.com?a=1 1&b=2 2&c=3 3"
    Dim sURLParameters = sURL.Split("?")
    Dim parameters As NameValueCollection

    parameters = HttpUtility.ParseQueryString(sURLParameters(1))

    sURL = sURLParameters(0) & "?"
    For i As Integer = 0 To parameters.Count - 1
        sURL += parameters.Keys(i).ToString & "=" & Server.UrlEncode(parameters.Item(i).ToString)
    Next

    Response.Write(sURL)

这一联系使我成为“四方”解决办法。

。 低温铀参数C# regex

做你想要做的事情的箱子方法不多。 从方案角度看,“安乐”,在“金色”中,它无法建立起来。

而且,乌尔都语党正在设立,拟通过URL派出,因此,它将取代(或)其他特性。

保证你能够 采用插手法,但这很可能造成不参加的结果。

你可以这样做:

string oldUrl = "http://www.example.com?a=1 1&b=2 2&c=3 3"
string oldUrlSplit = oldUrl.Split( ? );
string newUrl = oldUrlSplit[0] + HttpUtility.URLEncode(oldUrlSplit[1]);

显然,你想要取消检查等。

Edit:

我略微不提这一球。 您还将在<条码>和>上将旧的UrlSplit 等同起来;,随后在<条码>上将其分成“<>/代码>,然后在<条码>上,然后在<条码>上将“URLEncode”部分(在<条码><>>>>>后)分开。 参看“Anthony Pegram”,





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

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 do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签