S
SpaceMarine
did something change in the WebRequest object from .NET 1.1 to 2.0?
i swear i used to be able to pass relative URLs into the WebRequest
method, like so:
string relativePath = "/foo/bar.html";
WebRequest request = HttpWebRequest.Create(relativePath);
WebResponse response = request.GetResponse();
....now that generates an exception:
"Invalid URI: The format of the URI could not be determined."
so then i figured out how to create a full URL path ("http://...")
like so:
string relativePath = "/foo/bar.html";
//get the main url
string authority =
System.Web.HttpContext.Current.Request.Url.GetLeftPart
(UriPartial.Authority);
//add the supplied relative path
Uri uri = new Uri(authority + relativePath);
WebRequest request = HttpWebRequest.Create(uri.AbsoluteUri);
WebResponse response = request.GetResponse();
....that works, but im still wondering -- did this change?
thanks!
sm
i swear i used to be able to pass relative URLs into the WebRequest
method, like so:
string relativePath = "/foo/bar.html";
WebRequest request = HttpWebRequest.Create(relativePath);
WebResponse response = request.GetResponse();
....now that generates an exception:
"Invalid URI: The format of the URI could not be determined."
so then i figured out how to create a full URL path ("http://...")
like so:
string relativePath = "/foo/bar.html";
//get the main url
string authority =
System.Web.HttpContext.Current.Request.Url.GetLeftPart
(UriPartial.Authority);
//add the supplied relative path
Uri uri = new Uri(authority + relativePath);
WebRequest request = HttpWebRequest.Create(uri.AbsoluteUri);
WebResponse response = request.GetResponse();
....that works, but im still wondering -- did this change?
thanks!
sm