سؤال

I have a URL like : http://localhost.com/Dometic-Tou/french-with-flights-milano-10-12-may-2014.html

How can ı get this text from the URL : Domestic-Tou

I have got the link but all I want just Domestic-Tou from the link

I have tried:

Request.Path.Substring(Request.Path.LastIndexOf("/") + 1);
هل كانت مفيدة؟

المحلول

Don't use Request.substring. It will not give the expected result which you require. Instead use this.

string [] test = link.Split('/');

string required_subpart = test[3].ToString(); 

Note: the index is 3 here. Why because the url contains http://. So if you do not have http:// in your url, the index would be 1. Substitute it with whatever part you want in a url.

Let me know if this works for you, or I have an alternate solution for you.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top