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?
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
Related
I want my code to download the source/html of a website and be stored as a string.
For example
Dim source as string = html of website
This should work
Dim thesource As String = New System.Net.WebClient().DownloadString("http://the site u wanna look#")
I am making an FTP request and whenever the parameter remoteFilePath contains a string with "%20" I get an error that the file cannot be found. How can I get around this?
Dim remoteFileWriteTime As Date = Ftp.GetDateTimeStamp(remoteFilePath).ToLocalTime()
Note: I am not responsible for naming the files as it is not my server.
Try encoding the filename using this:
Dim baseUri as String = "ftp://SomeFtpServer/"
Dim file as String = "Strangely%20Named%20File.pdf"
Dim myUri as String = baseUri & HttpUtility.UrlEncode(file)
Dim remoteFileWriteTime As Date = Ftp.GetDateTimeStamp(myUri).ToLocalTime()
You might need to encode using Uri.EscapeDataString if HttpUtility isn't encoding it correctly. I'm not sure exactly which encoding scheme FTP expects offhand.
really need help, i need to make somehow to read from JSON array to VB.net string, specific value , this is my eg of array http://playnet.pro/client-files/gtracker/server.php?game=cssource&ip=216.52.148.47&port=27015
I made stream reader
Dim address As String = "http://playnet.pro/client-files/gtracker/server.php?game=cssource&ip=216.52.148.47&port=27015"
Dim client As WebClient = New WebClient()
Dim reader As StreamReader = New StreamReader(client.OpenRead(address))
Dim array As String = reader.ReadToEnd
but how to find my values or filter it? Thank you
For parsing JSON in VB.NET, you have option to use any one of the below libraries:
*) Newtonsoft.Json library You can use this from here
Tutorial: https://stackoverflow.com/a/20080586/4360419
*) JSON.NET library You can use this from here
Tutorial: You can also find the tutorial of this from the same side
You can also generate your VB.NET classes by your JSON from the below link
http://jsontodatacontract.azurewebsites.net/
Hey guys I am using a webrower to get an access token to a website. The website redirects the webrower to a url containing the access token the redirected url looks like this:
http://www.myurl.us/#access_token=e0a81edc8de4886b7cc514bcb2b93e06666bd0d8&expires_in=3600&token_type=bearer&refresh_token=72e302438349b32a627b12c92b01060169443a9b&account_username=
in the DocumentCompleted event for my webrowser I am using this code:
Dim pretoken As String
Dim url As String = WebBrowser1.Url.ToString
If url.Contains("myurl.us") Then
pretoken = WebBrowser1.Url.ToString
MessageBox.Show(pretoken)
End If
The message box only shows "myurl.us" and not the full url with the token i need. Anyway to get the whole url from the webbrowser?
Have you tried Url.AbsoluteUri.ToString(), like:
Dim url As String = WebBrowser1.Url.AbsoluteUri.ToString()
Be careful with AbsoluteUri it's not AbsoluteUrl
Dim sPagePath As String = System.Web.HttpContext.Current.Request.Url.AbsolutePath
in vb.net 2003 , how to disable images loading in webbrowser control
The way I have done this in the past is using Regex to replace image tags with empty quotes. Give the following a try, stick it into your DocumentLoaded event, or such:
origHTML = webBrowser.DocumentText
Dim newHTML as String
Dim regex as String = "<img.*/>"
newHTML = Regex.Replace(origHTML, regex, "", RegexOptions.Multiline)
webBrowser.DocumentText = newHTML
This should solve your problem.
Best Regards