There are four methods for invoking an InfoPath form or a browser-based version of the form on a server running InfoPath Forms Services. These methods consist of URLs that reference a form template file (.xsn), URLs that reference a form file (.xml) based on a form template, URLs that reference the built-in FormServer.aspx Web page, and those that contain a reference to a custom page containing the XmlFormView control. The first three types of URL support using query parameters to control aspects of the resulting form, including whether it will be opened in the InfoPath client or rendered in the browser, the location where the form will be saved, and the Web page that the user will be directed to when they close the form.
Important: |
|---|
|
By default, InfoPath forms will open in InfoPath even if a browser-enabled form is available. If InfoPath is not installed, the form will open in the browser. In addition to using query parameters to control how forms are opened, SharePoint library settings are used to control where forms are opened. To always force the form to open in the browser, choose Display as a Web page on the library's Advanced Settings page.
|
There are nine different parameters that can be used for opening InfoPath forms. Some parameters override others or cannot be used together, as noted in the table below. Name/value pairs other than those listed in the following table are interpreted as Input Parameters and passed to the form. Input parameters consist of one or more name/value pairs separated by the ampersand (&) character that are specified when a form template is opened from the command line or a batch file using the /InputParameters command-line option, or when a form template is opened from a URL. For more information about using input parameters, see the InputParameters property of the LoadingEventArgs class.
|
Parameter Name
|
Description
|
Allowed Values
|
|---|
|
XmlLocation
|
Used to open an existing form. The XmlLocation and XsnLocation properties are mutually exclusive; specifying values for both parameters will result in an error.
|
A valid URL to a form file (.xml) in the same site collection.
|
|
XsnLocation
|
Used to open a new form based on a form template. If an XsnLocation is specified in a URL using FormServer.aspx, a SaveLocation should also be specified if the Save and Save As buttons need to be displayed. The Source parameter should also be specified or the message "The form has been closed" will appear when the user closes the form. The XmlLocation and XsnLocation properties are mutually exclusive; specifying values for both parameters will result in an error.
|
A valid URL to a form template file (.xsn) published on the same site collection.
|
|
OpenIn
|
-
If a Source query parameter is specified, the default value is Browser.
-
If XmlLocation is specified, the default value is the setting used in the library.
-
If only XsnLocation is specified, the default value is PreferClient.
-
If Mobile is specified, the form will be redirected to the MobileFormServer.aspx page for rendering. The form template must be enabled for mobile support or an error message will be returned.
|
-
Browser
-
Client
-
PreferClient
-
Mobile
|
|
Source
|
The location to which the user will be redirected when the form is closed. The URL must be in the same site collection or an error will be returned.
|
A valid URL in the same site collection as the form.
|
|
Options
|
DisableSave is the only allowed value. It hides the Save and Save As buttons and disables saving the form when it is rendered in the browser.
|
DisableSave
|
|
SaveLocation
|
A Save As dialog box is displayed prompting the user for a filename, and then it is saved in the specified folder. An error is returned if the specified folder does not exist.
|
Any valid folder location on the site collection.
|
|
NoRedirect
|
Does not redirect to FormServer.aspx for client detection or rendering in the browser. Default value is false. If true and an XmlLocation or XsnLocation is specified, a File Download dialog is displayed when using Internet Explorer.
|
|
|
DefaultItemOpen
|
The OpenIn parameter should be used instead, and overrides the DefaultItemOpen parameter value. A value of 0 indicates that the request is from a document library and the InfoPath client was not detected. A value of 1 indicates that the request is from a document or form library that has the Display as a Web page setting.
|
|
Note: |
|---|
|
The query parameters and their associated values are not case-sensitive, but the corresponding properties of the XmlFormView control, such as the Options and SaveLocation properties, are case-sensitive.
|
Procedures
The following procedures require a site collection that you can publish form templates to, and the ability to create new sites in the site collection.
Placeholder values are used in the example URLs below. These values represent the following SharePoint and InfoPath items:
-
ServerName: A server running InfoPath Forms Services.
-
SiteCollection: The top-level site in a site collection.
-
FormLibrary: A form library or document library containing a browser-enabled form template.
-
Form1.xml: A form based on the template.xsn in FormLibrary.
-
NewFolder: A folder within the FormLibrary.
-
NewSite: A site within the SiteCollection.
The ~sitecollection value used in the following URLs is not a placeholder value. It is a special token used with InfoPath Forms Services that enables relative links and site collection-scoped URL addresses.
Using a URL with the XmlLocation parameter
Using a URL with the XsnLocation, SaveLocation, and Source parameters
Using a URL with the SaveLocation and Source parameters
Using a URL with the OpenIn=Browser parameter
Using a URL with the NoRedirect parameter
It is sometimes necessary to return a content stream of the XML representing the form. This is possible using the following methods.
Returning a Content Stream
-
Use a URL with the NoRedirect parameter.
-
Insert a "Translate:f" header in the HTTP GET request, such as:
myRequest.Headers.Add("Translate:f");
myRequest.Headers["Translate"] = "F";
-
Use the appropriate InfoPath user agent in the HTTP GET request, InfoPath.1 or InfoPath.2.
See Also