Name
UrlPathEncode
Synopsis
returnstring = Server.UrlPathEncode(s)
Returns a string containing a URL whose path portion is encoded using the URL literal equivalents of symbols such as slash (/), colon (:), and dot (.). The method also encodes any spaces in the remaining portion of the URL, since spaces in the query string may be unexpectedly truncated by some browsers.
Parameters
-
returnstring
A String variable to receive the encoded string from the method.
-
s
A String variable containing the URL to be encoded by the method.
Example
The code example declares two string variables, sets the value of
StrToEncode
, assigns the return value of
the Server.UrlPathEncode call to
StrToReturn
, and then writes the value to
the browser as part of a hyperlink:
Sub Page_Load( ) Dim StrToEncode As String Dim StrToReturn As String StrToEncode = "http://www.aspnetian.com/Chapter18/UrlPathEncode.aspx" StrToReturn = Server.UrlPathEncode(StrToEncode) Message.Text = "<a href=""UrlPathEncode.aspx?target=" & _ StrToReturn & """>" & StrToReturn & "</a><br/>" Message.Text &= "Target = " & Request("Target") End Sub
Notes
This method existed in classic ASP, but was undocumented.
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.