Reputation: 222720
When i hardcode the url in the code it works. I am trying to get the hostname and append the request. It gives this error,
Invalid URI: The URI scheme is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UriFormatException: Invalid URI: The URI scheme is not valid.
Source Error:
Line 44: string request = url.Scheme + "//" + url.Host + ":" + url.Port +"/accounts1/asp2netbridge.asp?sessVar=";
Line 45:
Line 46: HttpWebRequest _myRequest = (HttpWebRequest)WebRequest.Create(new Uri(request + sessionValue));
Line 47: _myRequest.ContentType = "text/html";
Line 48: _myRequest.Credentials = CredentialCache.DefaultCredentials;
Here is the code:
Uri url = HttpContext.Current.Request.Url;
string request = url.Scheme + "//" + url.Host + ":" + url.Port +"/accounts1/asp2netbridge.asp?sessVar=";
HttpWebRequest _myRequest = (HttpWebRequest)WebRequest.Create(new Uri(request + sessionValue));
Upvotes: 0
Views: 7703
Reputation: 2302
Add ":" before "//"
string request = url.Scheme + "://" + url.Host + ":" + url.Port +"/accounts1/asp2netbridge.asp?sessVar=";
Upvotes: 1