Building a System.Uri with a query string
-
please note: Yes I already posted this in the C# forum ( http://www.codeproject.com/script/Forums/View.aspx?fid=1649&msg=2604582[^] ), but at the suggestion of others said I might have better luck here. I give up, this seems impossible without the UriBuilder class... Well since .NET 1.1 when they made Uri(string, bool) obsolete... So here is my question: How do you build a System.Uri object in .NET compact framework that points to a "file://" scheme with passed query information? I've tried every valid (not obsolete) constructor for System.Uri meaning: * Uri(string) * Uri(string, UriKind) * Uri(base, string) * Uri(Uri, Uri) It didn't matter which I use because they don't have any affect on the outcome... Every constructor will escape the ? to hex as %3F which is not valid to use with query information!!! I can do this fine with strings but if I pass a string to the WebBrowser control it'll convert the string to a Uri object and have the problem again. So I need to build the correct Uri object and pass it to the WebBrowser control. MSDN says the following lie:
http://msdn.microsoft.com/en-us/library/system.uri(VS.80).aspx[^] wrote:
The Uri constructors do not escape URI strings if the string is a well-formed URI including a scheme identifier.
Proven by this example:(start a new smart device application and add this code to the form1.cs file)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace DeviceApplication1
{
public partial class Form1 : Form
{
public int demoValue = 4;
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(this.Form1_Load);
}void Form1\_Load(object sender, EventArgs e) { Uri htmlFile = new Uri(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), UriKind.Absolute); MessageBox.Show(
-
please note: Yes I already posted this in the C# forum ( http://www.codeproject.com/script/Forums/View.aspx?fid=1649&msg=2604582[^] ), but at the suggestion of others said I might have better luck here. I give up, this seems impossible without the UriBuilder class... Well since .NET 1.1 when they made Uri(string, bool) obsolete... So here is my question: How do you build a System.Uri object in .NET compact framework that points to a "file://" scheme with passed query information? I've tried every valid (not obsolete) constructor for System.Uri meaning: * Uri(string) * Uri(string, UriKind) * Uri(base, string) * Uri(Uri, Uri) It didn't matter which I use because they don't have any affect on the outcome... Every constructor will escape the ? to hex as %3F which is not valid to use with query information!!! I can do this fine with strings but if I pass a string to the WebBrowser control it'll convert the string to a Uri object and have the problem again. So I need to build the correct Uri object and pass it to the WebBrowser control. MSDN says the following lie:
http://msdn.microsoft.com/en-us/library/system.uri(VS.80).aspx[^] wrote:
The Uri constructors do not escape URI strings if the string is a well-formed URI including a scheme identifier.
Proven by this example:(start a new smart device application and add this code to the form1.cs file)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace DeviceApplication1
{
public partial class Form1 : Form
{
public int demoValue = 4;
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(this.Form1_Load);
}void Form1\_Load(object sender, EventArgs e) { Uri htmlFile = new Uri(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), UriKind.Absolute); MessageBox.Show(
After further testing this has been reported as a bug to the Visual Studio and .NET team via MS Connect: Bug ID 352533
-Spacix All your skynet questions[^] belong to solved
I dislike the black-and-white voting system on questions/answers. X|