|  Register
Deployment

Objectives

  • Deploying a 51Degrees.mobi Framework solution into a test or production (target) environment using the Visual Studio publish method.
  • Configuring a typical production Mobile Profile database.
  • Configuration IIS7 if used.
  • Using a valid production server license file.

Prerequisites

  • Windows 7, Windows XP SP2, Windows 2008 server, Windows 2003 server.
  • Visual Studio 2008 or 2010.
  • SQL Server 2005 or 2008 of any version installed on the development and target machine.
  • IIS 6 or IIS 7 with an empty web site or application created.
  • A 51Degrees.mobi Framework project which compiles and works as expected on the development machine.
  • The identity of the application pool used by the target environment.

Step 1 – Deploy the Mobile Web Application files

Right click on the web project and choose Publish Web. A dialogue similar to the following will appear.

Provide a target location where the files should be copied to. Ensure the options chosen match the ones shown in the above screen shot.

Click the Publish button to copy the files.

If the target location is not the folder used by the target web server manually copy the published files to the web server.

Step 2 – Mobile Profile Database

Note: This step is only required if Mobile Profile is part of the application. Move to Step 4 if Mobile Profile is not used.

Verify the following:

  1. Check a valid SQL server instance name exists using SQL Server Management Studio. Remember the SQL service instance name is in the form [host name]\[instance name]. For example; sqlserver.example.local\MSSQLSERVER.
  2. The database name you intend to use does not already exist. Mobile Profile databases should not be combined with other databases.
  3. That the authentication credentials of either the logged in user, or the SQL server login, have the ability to create new database.

Open a command prompt and navigate to the installation folder.

If the target SQL server instance is configured to use Windows Authentication enter the following command.

fiftyOne_regsql.exe –S server –D database –E

If SQL Server Authentication is being used enter the following command.

fiftyOne_regsql.exe –S server –D database –U username –P password

Example:

If your SQL instance name was “sqlserver.example.local\SQLEXPRESS”, the database name required was “MobileProfile”, and SQL Server authentication is being used with a user name of “sa” and password of “password” the following command would be used to create the Mobile Profile database.

fiftyOne_regsql.exe –S sqlserver.example.local\SQLEXPRESS –D MobileProfile –U sa –P password

Output similar to the following should appear.

Installing MobileProfile schema to database MobileProfile

................................................................................

MobileProfile installation completed.

Tip: We’ve noticed incorrect characters are sometimes included in command lines pasted into a command prompt window. Please ensure the command line is entered from the keyboard and cut and paste avoided.

SQL Server must be configured so that the identity of the Application Pool used by IIS has read and write access to the newly created mobile profile database. A login may need to be created for the Application Pool, or a group to which it belongs, depending on the configuration of the target environment.

Step 3 – Change the Connection String Configuration

Open the web.config file in the published output folder from Step1.

Locate the profileConnectionString element of the connectionStrings collection. It will be similar to the following.

<add name="profileConnectionString" connectionString="Data Source=.\SQLExpress;Integrated Security=True;Database=MobileProfile;AttachDBFilename=|DataDirectory|MobileProfile.mdf;User Instance=True;Asynchronous Processing=True;"/>

Remove the User Instance and AttachDBFilename segments of the connectionString. These are only needed during development with SQL Express. Replace .\SQLExpress with the SQL server instance name, and MobileProfile with the database name from Step2. The connectionString will now look similar to the following.

Data Source=[server];Integrated Security=True;Database=[database];Asynchronous Processing=True;

If SQL Server Authentication is being used then set Integrated Security to False, and provide a user name and password. The connectionString will now appear similar to the following.

Data Source=[server];Integrated Security=False;User=[username];Password=[password];Database=[database];Asynchronous Processing=True;

If Integrated Security is set to true the identity of the process accessing the Mobile Profile database will be that of the IIS Worker Process or Application Pool and not the currently logged in user. Additional SQL Server or IIS configuration may be required which is beyond the scope of this tutorial.

Step 4 – Internet Information Server 7

Note: This step is only required if the deployed web server is IIS 7 or greater. If the target environment is IIS 6 this step can be skipped.

Locate the httpModules and httpHandlers section of the system.web element of web.config file. Comment these out as they are not supported by IIS 7. The modules and handlers sections of the system.webServer element will be used.

Tip: To avoid editing the web.config file for every deployment we suggest excluding the web.config from publication by setting the Build Action to None after Step 1 is completed for the 1st time. This ensures the target environments web.config is not overwritten.

Step 5 – Validate the License Key

If a valid license file has not been included in the deployment an exception similar to the following will be thrown when first access.

A valid license file could not be found for the product. Please visit 'http://51degrees.mobi/purchase.aspx' and obtain a valid license file and place it in the /bin directory of the application.

A valid production server license key needs to be available in the bin folder of the application. Create a text file in the bin folder with the extension .lic and paste the production server, or combined license, key purchased from 51Degrees.mobi into the file. The license key can be found on the invoice received from 51Degrees.mobi.

When the page is refreshed, and a valid license file provided, the exception will no longer appear.

Tip: Use a different name for the .lic file in the target environment from the one used in development. Only the extension is important. Therefore the name of the file can be anything meaningful to your configuration. For example; the production server could use a license file named Production.lic, whilst the developers use a file name Development.lic. The Production.lic key need only exist in the target, or production, environment’s bin folder.

Troubleshooting

If your web site is returning a 500 error while using the Framework with IIS 7 or IIS 8 with an error message referring to handlers you may need to enable to unlock the handlers configuration. Enter the following command into the command prompt:

%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers

For more information see Locking and Unlocking Configuration section of the AppCmd page.