• Hello and welcome to our new forums. We upgraded our forum sites to a more robust and modern system which we hope you will enjoy. Be sure to check out your profile by clicking the button on the top right and configure your preferences, signature, time zone, avatar, etc. as you wish. If you need help with using this new forum'ware try the help link on the bottom right.

    Click here to review your account now.

Using GenericUriParserOptions in a Net Compact Framework 3.5 project

J Trahair

Well-known member
Joined
May 14, 2008
Messages
175
Location
Spain
Programming Experience
10+
Hi. I have a handheld terminal on Windows CE6.0 Net CF3.5, and need to send urls to a web server without letting it include the (buggy) extra backslash you get when you convert the url to %5C and %2F etc. (encode all the parameters using the RFC 3986 standard).

To this end I need to use GenericUriParserOptions, specifically DontUnescapePathDotsAndSlashes. I've been onto a few MS pages
eg. https://msdn.microsoft.com/en-us/library/system.genericuriparseroptions(v=vs.80).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

where it says:

Code:
'Declaration
<FlagsAttribute> _
Public Enumeration GenericUriParserOptions
'Usage
Dim instance As GenericUriParserOptions
The 'Dim instance As GenericUriParserOptions' is OK but the declaration doesn't make any sense to me or to the compiler. I'm expecting a function that does something like this:

Code:
Dim request As System.Net.HttpWebRequest = WebRequest.Create("http://" & DontUnescapePathDotsAndSlashes(myURL))
but I don't understand the declaration bit or how to actually prevent the stray backslashes in the url after encoding the parameters.

Thank you for your help.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,027
Location
Sydney, Australia
Programming Experience
10+
You should do some general reading on enumerations and how to use them. Your code example is treating it like it's a method, which it's not. It's a value, so you pass it to a method as an argument. If you've read that page you linked to then you'd read this:
You can combine any of these options to configure a generic URI parser by passing the options as a parameter to the System.GenericUriParser constructor.
So, you create a GenericUriParser object and pass the value GenericUriParserOptions.DontUnescapePathDotsAndSlashes to the constructor.
 
Top Bottom