How to use
If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.
At design time
- Verify that the Web ADF for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
- In Windows Explorer, navigate to <ArcGIS install location>\DeveloperKit10.0\Samples\ServerNet. This folder contains a folder called Common_SimpleServerTask containing CSharp and VBNet folders.
- Open the folder of the language you're going to use—CSharp or VBNet—and copy the Common_SimpleServerTask_<language> folder to c:\inetpub\wwwroot. The <language> variable can be either CSharp or VBNet.
- Open the IIS Manager from Control Panel > Administrative Tools > Internet Information Services (IIS) Manager or Internet Information Services.
- In the console tree view on the left, navigate to Local Computer > Web Sites > Default Web Site, open the Common_SimpleServerTask_<language> folder, right-click the SimpleServerTaskWebApp_<language> folder, and click Properties. The Properties dialog box opens.
- Click the Directory tab, click the Create button in the Application Settings section, then click OK to close the Properties dialog box.
- Start Microsoft Visual Studio 2008 or 2010 and open the Common_SimpleServerTask_<language><vs_version> solution (for example, Common_SimpleServerTask_CSharp2008.sln) located in c:\inetpub\wwwroot\Common_SimpleServerTask_<language>. The <vs_version> references the Visual Studio version of the solution, either 2008 or 2010.
- In Solution Explorer, right-click the SimpleServerTaskWebApp_<language> project, and select Set as StartUp Project.
- Right-click Default.aspx, and select Set As Start Page.
- Save the solution.
- Click the Debug drop-down menu and click Start Debugging. The custom task class library builds and is added to the Web project. The Default.aspx page displays a menu item to initialize the custom server task and the dialog for the custom server task control.
- To add the custom task to the Visual Studio toolbox, follow the steps in the Add the custom server task to the Visual Studio toolbox section below.
- To distribute the custom task for use in the Manager application, follow the steps in the Add the custom task to Manager section below.
Add the custom server task to the Visual Studio toolbox
- While in design mode of the default.aspx, right-click in the toolbox, select Add Tab, and type a name for the new tab (for example, Custom Task Controls).
- Right-click the new tab and select Choose Items. The Choose Items dialog box opens.
- Click the Browse button, navigate to the location of the SimpleServerTask_CSharp.dll, and click Open. Two new controls are added to and selected in the Choose Items dialog box.
- Select and check the SimpleServerTask_CSharp box, then click OK to close the dialog box. The new tab contains the custom server task control.
Add the custom task to Manager
- By default, the custom task project includes a key it uses to sign the class library. You can change this by generating your own key using the sn.exe utility included with the .NET software development kit (SDK). Open a Visual Studio 2008 command prompt and type: sn -k MyKeyPair.snk
- In Visual Studio, right-click the class library project, select Properties in the context menu, click the Signing tab, check the Sign the assembly check box, and type the correct path to the key. This confirms that the key will be used to sign the custom server task assembly.
- Use the gacutil.exe utility included with the .NET SDK to add the assembly to the Global Assembly Cache (GAC). In a Visual Studio 2008 Command Prompt, type: gacutil -i SimpleServerTask_CSharp.dll
- To add the custom task details to the Manager Tasks.xml file, in the App_Data folder for the Manager Web application (for example, C:\Inetpub\wwwroot\ArcGIS\Manager\App_Data), open the Tasks.xml file in a text editor, and add the following line in the <Tasks> tags: <Task Name="SimpleServerTask_CSharp" DisplayName="Simple ServerTask CSharp" Type="SimpleServerTask_CSharp.SimpleServerTask_CSharp, SimpleServerTask_CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b2d9a257d5f63add" TagPrefix="simpleServerTaskCS" />
- Confirm the content of this entry, namely the version and public key token, by opening a Visual Studio 2008 or 2010 command prompt and typing: gacutil -l SimpleServerTask_CSharp
- Restart IIS by opening a Visual Studio 2008 or 2010 command prompt and typing: iisreset. Manager can now recognize the new task and will make it available in the Tasks dialog box during Web application creation.
At run time
- Browse to the viewer uniform resource locator (URL) (for example, http://localhost/Common_SimpleTask_CSharp/SimpleTaskWebApp_CSharp).
- The custom task control should be visible when the page loads. If not, click the menu to initialize the Tasks window.
- In the custom task, type a value in the text box and click the Execute button. The TaskResults control displays the results (in this case, the time on the Web server is returned with the text entered in the text box as a child node).
- In Manager, login and create a Web application.
- During the process, in the Tasks window, select the Simple Task CSharp task and add it to the current list of tasks to be included in the Web application.
- Highlight the custom task in the Current Tasks window and click the Configure button.
- Set the name of the custom task window, the button text, and the background color of the control.
- Click OK, then click Finish. The Web application opens in a new browser window.
- Initialize the custom task in the Web application by expanding the Tasks panel and clicking the custom task menu.
Common_SimpleServerTask_CSharp\SimpleServerTask_CSharp.cs | Custom task implementation code. |
Common_SimpleServerTask_CSharp\SimpleServerTaskWebConfigurator_CSharp.cs | Custom task implementation that provides a configurable dialog in Manager. |
Common_SimpleServerTask_CSharp\SimpleServerTaskDesigner_CSharp.cs | Custom task implementation code that provides verbs to configure the custom task off the control in Visual Studio design time. |
Common_SimpleServerTask_CSharp\ButtonTextEditorForm.cs | Windows form initialized off a custom verb on the task in Visual Studio design time. |
Common_SimpleServerTask_CSharp\ButtonTextEditor.cs | Logic for Windows form initialized off a custom verb on the task in Visual Studio design time. |
Common_SimpleServerTask_CSharp\Properties\AssemblyInfo.cs | Assembly-specific information used when compiling the assembly. Note the custom tag prefix. |
Common_SimpleServerTaskWebApp_CSharp\Default.aspx | User interface for the Web application. |
Common_SimpleServerTaskWebApp_CSharp\Default.aspx.cs | Code behind the user interface. |
Common_SimpleServerTask_VBNet\SimpleServerTask_VBNet.vb | Custom task implementation code. |
Common_SimpleServerTask_VBNet\SimpleServerTaskWebConfigurator_VBNet.vb | Custom task implementation that provides a configurable dialog in Manager. |
Common_SimpleServerTask_VBNet\SimpleServerTaskDesigner_VBNet.vb | Custom task implementation code that provides verbs to configure the custom task off the control in Visual Studio design time. |
Common_SimpleServerTask_VBNet\ButtonTextEditorForm.vb | Windows form initialized off a custom verb on the task in Visual Studio design time. |
Common_SimpleServerTask_VBNet\ButtonTextEditor.vb | Logic for Windows form initialized off a custom verb on the task in Visual Studio design time. |
Common_SimpleServerTaskWebApp_VBNet\Default.aspx | User interface for the Web application. |
Common_SimpleServerTaskWebApp_VBNet\Default.aspx.vb | Code behind the user interface. |
Download the files for all languages
See Also:
Creating a custom server taskServer task Manager integration