Search code examples
asp.neturlc#-4.0formatted

How to get string from formatted url in asp.net c#


Suppose We are on the page www.abc.com/apple-store

then how to get string apple-store in asp C# code.

to store into another variable.


Solution

  • You can use string.last() to extract it.

    string lastPartUrl =HttpContext.Current.Request.Url.AbsoluteUri.Split('/').Last();