How To: Create a simple ArcGIS Server ASP.NET web page
Instructions provided describe how to create a simple ArcGIS Server ASP.NET web page. For diagnostic purposes it is helpful to use a minimal application, where possible, to test whether ArcGIS Server and the .NET Application Developer Framework (ADF) are configured and working properly.
Before running this sample the .NET ADF needs to be installed on the web server, ArcGIS Server needs to be installed and working, and all system requirements need to be met.
- Create an ASP.NET application directory. This can be done by way of the following steps:
- Create a folder under your <drive>:\inetpub\wwwroot directory.
- Use the IIS Manager to view the properties of the newly created folder.
- Click the Create button, on the Directory tab, to create an ASP.NET application.
- Copy the code below into a text editor and save it as an *.aspx file. Then edit it with the following modifications:
- Change the Host attribute in the esri:map tag to be the machine where the ArcGIS Server Server Object Manager is running.
- Change the ServerObject to a running MapServer server object. Keep in mind that the server object names are case sensitive. 'World' is different than 'world'.
<%@ Register TagPrefix="esri" Namespace="ESRI.ArcGIS.Server.WebControls" Assembly="ESRI.ArcGIS.Server.WebControls, Version=22.214.171.124, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86" %> <html> <head> </head> <body> <form id="WebForm" method="post" runat="server"> <esri:map id="TheMap" UseMIMEData="True" Width="400px" Height="400px" style="LEFT: 200px; POSITION: relative; TOP: 30px" runat="server" BorderStyle="Solid" BorderColor="200,170,35" BorderWidth="10px" ServerObject="PoliticalEarthquakes" Host="tao" AutoFirstDraw="True"> </esri:map> </form> </body> </html>
- Create a web.config file in the ASP.NET application directory. A sample web.config file is shown below.
- Configure the file to use an account that is in the agsusers group on the ArcGIS Server machine.
- Storing a username and password in clear text in the web.config file may not be a secure way to store this information. Microsoft provides mechanisms to encrypt this information. This example is intended only for diagnostic purposes.
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <!-- Session state must be enabled for the map control --> <sessionState mode="InProc" /> <identity impersonate="true" userName="SomeDomain\SomeAcct" password="SomePassword" /> </system.web> </configuration>
- Test the application in a browser by typing http://servername/virtualdirectory/myapp.aspx.
- If ArcGIS Server is installed and the .NET ADF is working then a map should appear.
- When done testing delete the files in the directory - in particular the web.config file if it contains a clear text password.