Page.URL Method

The URL method generates a URL based on the specified file name and an optional list of name/value arguments. This URL includes the server name, the virtual directory in which the file is stored, and the name of the file itself.

Additionally, if the StandardSManager for the application is initialized in URL mode, the URL method uses the value stored in the Application object’s MSCSSIDUrlKey variable as the name in a name/value pair, the value of which is the current shopper ID.

The method applies URL encoding to the values passed in.

Syntax

Page.URL(Filename, Arguments)

Parameters

Filename
The name of the file to reference in the URL.
Arguments
An optional list of name/value pairs.

Remarks

The URL method spares the site builder the need to map a file to the HTTP path to that file, or to build name/value pairs manually into the query string appended to the URL. For example, assume the following call to URL:

<%= Page.URL("filename.asp", "sku", sku) %>

This call resolves to the correct HTTP path to filename.asp, and appends the sku name and sku value to that URL as follows:

http://host_name/virtual_directory/filename.asp?sku=13428

The value for host_name is determined by the contents of the site dictionary’s NonsecureHostName value, or in the case of the SURL method, the SecureHostName value. The virtual_directory is determined automatically from the scripting context.

For sites in which the StandardSManager is initialized in URL mode, a call to URL, SURL or URLShopperArgs appends the current customer’s shopper ID to the URL argument list. The name of the argument passed in the URL is stored in the Application object’s MSCSSIDUrlKey variable. Thus, where the Application object’s MSCSSIDUrlKey variable is initialized as Application("MSCSSIDURLKey") = "mscssid" and where the StandardSManager is running in URL mode, the script:

<%= Page.URL("filename.asp", "sku", sku) %>

resolves to the following:

http://host_name/virtual_directory/filename.asp?sku=13428&mscssid=Q0H4SE915ASH2KC000Q79QB1E

You can generate the parts of a URL separately, using the methods and properties shown in the following table.

Elements of a URL

URL Part Obtained using Example
Domain page.URLPrefix
page.SURLPrefix
http(s)://www.microsoft.com
Directory page.VirtualDirectory clocktower
Arguments page.URLArgs() sku=1342
Arguments with shopper ID page.URLShopperArgs() sku=13428&current_shopper=12345

Related Topics


© 1997-1998 Microsoft Corporation. All rights reserved.