Sunday 15 May 2011

c# - How to escape url encoding? -


I am creating a link that creates URL parameters that include links to URL parameters. The problem is that my Is there a link like this

  http: //mydomain/_layouts/test/MyLinksEdit.aspx? Auto = true & source = http: // vtss-sp2010hh: 8088 / AdminReports / helloworld.aspx? Pdfid = 193 and url = http: // vtss-sp2010hh: 8088 / AdminReports / helloworld.aspx? Pdfid = 193% 26pdfname = 5.6% 20Upgrade & title = 5.6 upgrade   

< Code> auto is not read or is

url bookmark is linked

The title is source where you have to go after adding or canceling

url code> is the name of the bookmark

The values ​​of url and titles are entered in two fields, then cancel the user saved or T will need to click on. The problem occurs when the bookmark enters the values ​​in the page field, it will decode them. Then if you try to save, it will not let you save because there is a place in the pdfname value in the url value. If there is no need for a blank space, then basically, I want that after entering the area, it will still be % 20 rather than a place.

There is no problem with source , auto , or title , just url . ..

Is there a way to solve this? Maybe I like a special escape character like % 20 ?

Can use for note: I can not modify bookmark page.

I am using c # / asp.net to create a link and go to it.

Thanks

Since the .NET Framework 4.5 you have WebUtility.UrlEncode < / Code>.

It resides in System.dll , so it does not need any additional reference.

This avoids the characters properly for the URL, unlike the Uri.EscapeUriString

Uri.EscapeDataString , therefore it can be used for POST requests

  System.Net.WebUtility.UrlEncode (urltext)   

Another option

  System.Uri.EscapeDataString ()    

No comments:

Post a Comment