Need to retrieve only website name from full url in C# [Resolved]

Posted by Vishnupavadi under ASP.NET on 7/23/2013 | Points: 10 | Views : 1173 | Status : [Member] | Replies : 7
Hi guys,

Can anyone help me please,
Below i there is full url path of page.
http://www.dotnetfunda.com/articles/csharp/introduction.aspx
http://www.dotnetfunda.co.in/interview/asp.net/whatisdonet.aspx

But i want to take only website name including http like - "http://www.dotnetfunda.com" , "http://www.dotnetfunda.co.in"

'm using asp.net C#, i didn't get proper solution.
Thanks in Advance.




Responses

Posted by: Kmandapalli on: 7/24/2013 [Member] Silver | Points: 50

Up
0
Down

Resolved
Hi,

Mark as answer if you are satisfied...

Thanks,
Shree M.

Kavya Shree Mandapalli

Vishnupavadi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 7/23/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

Try this code

Uri originalUrl = new Uri("http://www.dotnetfunda.com/articles/csharp/introduction.aspx "); // Request.Url
string domain = originalUrl.Host; // www.dotnetfunda.com
string domainUrl = String.Concat(originalUrl.Scheme, Uri.SchemeDelimiter, originalUrl.Host);
//http://www.dotnetfunda.com

Mark as Answer if satisfied.........

Thank You,
Kavya Shree M.



Kavya Shree Mandapalli

Vishnupavadi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vishnupavadi on: 7/24/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks Kavya... I 'll check with your code snippet it .

Vishnupavadi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja_89 on: 7/25/2013 [Member] Starter | Points: 25

Up
0
Down
Hai
Store the url in string format

String url="www.dotetfunda.com\articles\charp.html";
String che= url.remove( zero based index value);

Hope it will work for you
Mark answer if you got a solution

Regards



Vishnupavadi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 7/30/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

Can you please mark it as answer.............

Regards,
Shree M.

Kavya Shree Mandapalli

Vishnupavadi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vishnupavadi on: 7/30/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks Kavya its working as i need. :)

Thanks to Raja_89 for response...


Vishnupavadi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 7/30/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
--You can do like the below
[code]string str = "http://www.dotnetfunda.com/articles/csharp/introduction.aspx";
int strPos = str.IndexOf("\");
string retURL = "";
if (strPos >0)
{
retURL = str.Substring(0, strPos-1) ;
}[/code]


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Vishnupavadi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response