KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is there a method that tests if 2 URLs are equal, ie point to the same place? I am not talking about 2 URLs with different domain names pointing to the same IP address but for example, 2 URLs that point to the same .aspx page: http://example.com/Products/Default.aspx?A=B&C=D&E=F is equal to these: http://example.com/Products/Default.aspx http://example.com/Products/ ~/Products/Default.aspx ~/Products/ Note/assumtions QueryString Values are Ignored ASP.NET (Pref C#) Default.aspx is the default page ----UPDATE---- This is a very crude method that tests a URL to see if matches the current URL: I tried creating a new Uri() with both the local and check URLs but dont know that works and went down the string checking avenue. The implementation of the SiteMapProvider skips this step if the URL starts with "HTTP" as this assumes an external URL. Since I have a SaaS framework that will always ensure relative paths (as these can be on different subdomains) it easier to strip things down. Any comments on optimization? I guess for a start we can pass in a variable containing the current URL? Not sure of the overhead of calling HttpContext.Current.Request.Url.LocalPath many times? /// <summary> /// Assumes URL is relative aspx page or folder path /// </summary> /// <param name="url"></param> /// <returns></returns> public static bool CurrentURLMatch(string url) { string localURL = HttpContext.Current.Reques
Tags (comma-separated)
Save Edits
Cancel