user4281510
user4281510

Reputation:

How can I use decode encoded URL using VB.NET

I have an encoded url as follows;

dim inStr As String ="https%3A%2F%2Fmyweb%2page1%2Egov%2Emy%3A448%2Fserver%2FForm%3Fuserid%3Dtrouble" 

I want to decode the url and assign this url to my webBrowser control.

From this thread:

Dim decodedUrl As String = HttpUtility.UrlDecode(encodedUrl)

I got a snippet to decode but am not using web application, am using windows application; can anyone suggest me the best way to do this?

Upvotes: 2

Views: 1995

Answers (1)

user3962541
user3962541

Reputation:

you can use Uri.UnescapeDataString() method as follows:

    Dim inputURL As String = "https%3A%2F%2Fmypage%2Eme%2Epage%2Esample%3A448%2Flfserver%2FForm%3Fuserid%3DTrouble"
    Dim outputURL As String = Uri.UnescapeDataString(inputURL)

The output will be https://mypage.me.page.sample:448/lfserver/Form?userid=Trouble

Upvotes: 1

Related Questions