Click here to Skip to main content
15,895,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.. how can get the default URL
On first load I have this URL - www.Status_Maker.com then after user transaction the URL became www.Status_Maker.com?MakerID=1234&Status=True

My question is how can i get the url "www.Status_Maker.com" because using the Request.Url.ToString i'm getting the "www.Status_Maker.com?MakerID=1234&Status=True"
I want to have the url = "www.Status_Maker.com"
Posted
Updated 5-Sep-11 0:00am
v2

VB
Dim host As String = String.Format("{0}://{1}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host)
 
Share this answer
 
thanks all for the help... i used this code in my reference http://forums.asp.net/t/680870.aspx/1?Getting+URL+without+Query+String[^][^] thanks TJ
 
Share this answer
 
you can use two different methods -
1.
string url = "www.Status_Maker.com?MakerID=1234&Status=True";
Uri uri = new Uri(url);
Console.WriteLine(uri.GetLeftPart(UriPartial.Path));
2.
string _url = "www.Status_Maker.com?MakerID=1234&Status=True";
string[] str= _url.Split('?');
string _desiredUrl = str[0];

and there can be many other ways also to do the same
 
Share this answer
 
You are looking for base url in your request. This should help.

string url =
    HttpContext.Current.Request.Url.Scheme
    + "://"
    + HttpContext.Current.Request.Url.Authority
    + HttpContext.Current.Request.ApplicationPath.TrimEnd('/')
    + '/';
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900