Error!
Success!

C# Get RelativeUrl from AbsoluteUrl

0
kicks

C# Get RelativeUrl from AbsoluteUrl  (Unpublished)

Getting relativeUrl from absoluteUrl is very simple. We have a class System.Uri which takes absolute/full url as a string parameter and gives the relative url. using System; private static string GetRelativeUrl(string fullUrl) { try { Uri uri = new Uri(fullUrl);//fullUrl is absoluteUrl string relativeUrl = uri.AbsolutePath;//The Uri property AbsolutePath gives the relativeUrl return relativeUrl; } catch (Exception ex) { return fullUrl; //throw ex; } }


Kicked By:
Drop Kicked By: