Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
4.11/5 (2 votes)
See more:
I have mentioned below that i want. Ex.2 is urgent:

Ex.1
input string : horse.shop.com
output url : http://horse.shop.com/

Ex.2
input string : shop.com/horse
output url : http://shop.com/


Thanks in advance.

Respectfully,
Emon Mahmud
Posted
Updated 16-Feb-14 21:46pm
v2
Comments
Ankur\m/ 17-Feb-14 3:52am    
If it's a web application, check out your Request object. And if it is not, you can either use regular expression or simple string operations to the get the value.

check url with regex format and if it is not valid then add http or https at started of string ... u will get path of it
 
Share this answer
 
if Real URL: http://shop.com/horse

url = HttpContext.Current.Request.Url.AbsoluteUri;
// http://shop.com/horse

string path = HttpContext.Current.Request.Url.AbsolutePath;
// /horse

string host = HttpContext.Current.Request.Url.Host;
// shop.com
 
Share this answer
 
Comments
Emon Mahmud 17-Feb-14 4:04am    
We don't bother about real/fake URL. I want just out put string
Roozbeh Maheronnaghsh 17-Feb-14 4:09am    
What do u mean by output string.Explain more please.URL is string also

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