The Wine Spies - Undercover Deals, Exceptional Wines, Once Each Day...

Captured Technology

Getting the Current URL in Asp.Net

Nov 05 2009

Getting the Current URL in Asp.Net

We had the need within a custom asp.Net control this week to obtain the current URL, compare it to a value, and take action if the values matched. I found online some quick and easy code to determine the URL of the page the control is loading on and the function to take action was developed rather quickly thereafter.

Here is the basic code to get the URL:


And using a combination of the Mid function and the Instr function, we are able to match values regardless of the environment the code is running in:

If Mid(strLinkURL, InStr(strLinkURL, "Pages")) = Mid(Request.Url.ToString(), 
InStr(Request.Url.ToString(), "Pages")) Then
       strReturn = "" & strLinkText & ""
       strReturn = "" 
& strLinkText & ""
End If
© 2009

Blog Directory

Latest technology news.
 Patrick Stevens
 447  245582  10/31/2018




Blog Calendar