user353089
user353089

Reputation: 31

Special character into querystring .NET

I need to send the follow querystring:

http://prod.intranet.siemens.com.br/drvs/index.aspx?page=2&pag=4&varpatch=%20C:\Documents%20and%20Settings\OPE253\My%20Documents\Ca$@#!

Then i try to assing this to a string,but .NET break string at

   http://prod.intranet.siemens.com.br/drvs/index.aspx?page=2&pag=4&varpatch=%20C:\Documents%20and%20Settings\OPE253\My%20Documents\Ca$@

'#" do not appears in querystring

Any ideas?

Upvotes: 1

Views: 1788

Answers (1)

ChrisF
ChrisF

Reputation: 137148

No, because "#" is a reserved character. It's used to link to a specific location in a web page:

http://en.wikipedia.org/wiki/HTML_anchor#Overview

So browsers split the URL at the "#".

You'll need to encode the "#" as "%23"

You need to use String.Replace:

Dim outputURL As String = inputURL.Replace("#", "%23")

or HttpUtility.UrlEncode (only encode the querystring):

Dim outputQueryString As String = HttpUtility.UrlEncode(inputQueryString)

Upvotes: 6

Related Questions