Name
URLEncode —
Server.URLEncode (strURL
)
Synopsis
Encodes a string that can then be sent over the address line as a query string.
Parameters
-
strURL The string value you want to encode to send over the address line as a query string.
Example
<% ' The following encodes the URL ' http://www.myserver.com/apps/search.asp Dim strOldURL Dim strNewURL strOldURL = "http://www.myserver.com/apps/search.asp" strNewURL = Server.URLEncode(strOldURL) ' This encoding results in the following string value being ' placed in the strNewURL variable: ' http%3A%2F%2Fwww%2Emyserver%2Ecom%2Fapps%2Fsearch%2Easp ' This new string value could be used in a query string to ' represent a "next script," as demonstrated here: %> <HTML> <HEAD><TITLE>URLEncode Example</TITLE></HEAD> <BODY> <FORM ACTION="/apps/CalcAndRedirect.asp?newURL=<%=strNewURL%>" METHOD = POST> <INPUT TYPE = TEXT NAME = "First Value"> <INPUT TYPE = TEXT NAME = "Second Value"> <INPUT TYPE = SUBMIT NAME = "Calculate Results"> </FORM> </BODY> </HTML>
Notes
The URLEncode method, like the HTMLEncode method, is straightforward
and easy to use. It is imperative that you use the URLEncode method
any time you are forced to send information over the address line
instead of posting information using the POST
method. If you do not encode your information and place it into the
QueryString collection (through the GET method),
its interpretation is unpredictable, depending on the data sent.
If you send information in the query string (i.e., from visible frame ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access