Publish Web Deployment of an ASP.NET Web Forms Application
- 6 minutes to read
In this lesson, you will learn how to deploy an ASP.NET Web Forms XAF application via the Publish Web method.
Deploying an ASP.NET Web Forms application via the Publish Wizard method is very similar to the Xcopy Deployment of a Windows Forms Application method. The difference is that you can upload application files to the Web Server without leaving Visual Studio. All the other steps are the same.
Perform the following steps at the Developer Workstation to prepare the ASP.NET Web Forms application for Publish Web deployment.
Open the MySolution solution in Visual Studio. In the Solution Explorer, expand the MySolution.Web\References folder. Select assemblies whose names start with “DevExpress”. If you use Entity Framework, third-party controls or modules, select their assemblies as well. In the Properties window, set the CopyLocal property to True.
Repeat this step for all module projects that are referenced in the application project (e.g., MySolution.Module and MySolution.Module.Web).
Note
If your application is localized and uses pre-built satellite assemblies, the satellite assemblies should be deployed with the application. So, create a folder in the MySolution.Web project. The name of this folder should be the language culture code (for instance, “de” for German). Add the required satellite assemblies to this folder (right-click the folder and choose Add | Existing Item…). Set the satellite assemblies’ Copy to Output Directory property to Copy if newer.
Change the Active Solution Configuration from Debug to Release.
Open the MySolution.Web\Web.config file. In the system.web section, set the compilation’s debug option to false
<system.web> <!-- ... --> <compilation debug="false">
- Build and run the ASP.NET Web Forms application.
- Check that the application performs correctly and close it.
Ensure that the MySolution\MySolution.Web folder contains application files.
- If the MySolution\MySolution.Web\Bin folder contains PDB files, remove them.
Now the ASP.NET Web Forms application is ready for Publish Web deployment.
Note
If you don’t have Internet Information Services (IIS) on your server, you can install it using the Turn windows features on or off tool. To run ASP.NET Web Forms applications, you should check the Internet Information Services, then expand it, navigate to the World Wide Web Services\Application Development Features and check the appropriate features related to the .NET and ASP.NET Web Forms technologies.
Create an application folder on the Web Server (for instance, D:\Sites\MySolution). Use the Internet Information Services (IIS) Manager to add the mysolution website linked to the D:\Sites\MySolution physical path in the server file system. The IIS Manager is accessible from the server Start Menu | Administrative Tools. Make the application folder shared and writable for the Developer Workstation (for instance, by FTP)
Note
If you are deploying an application to remote web hosting, you are not required to create a folder via the IIS Manager. Create the mysolution subfolder in the web root folder (typically, it is named wwwroot). Contact hosting support if you experience problems accessing the web root folder.
Perform this step on the Developer Workstation. Right-click the MySolution.Web project in Solution Explorer. Choose Publish… Specify the target location in the invoked Publish Web dialog and click Publish.
Choose Custom publishing target and follow the instructions from the wizard.
You may be asked for credentials. Provide a valid user name and password for your web server. The application will be uploaded.
As an ASP.NET Web Forms application project has references to several module projects (e.g., MySolution.Module.Web and MySolution.Module), it is required to deploy referenced assembles of these modules. Copy required assemblies from the output folders of module projects (i.e., MySolution\MySolution.Module.Web\Bin\Release and MySolution\MySolution.Module\Bin\Release) to the Bin subfolder of the application folder (e.g., D:\Sites\MySolution\Bin). You can skip overwriting files that are already copied.
Note
If you want to manually upload files later, you can specify a local folder as a target location and upload it to the server at that time.
Open the web browser, either locally at the Web Server or from any remote workstation which has access to a web server. In the browser navigation bar, type the “http://localhost/mysolution/“ URL if you launched a Web Server local browser, or the “http://<your_server_name>/mysolution” URL, if you launched a browser at a remote workstation. Press ENTER. If the Web Server displays an error message reporting a missing assembly, copy the required assembly to the Bin folder on a Web Server.
Here is the location on the Developer Workstation where you can get the required assembly: %PROGRAMFILES%\DevExpress 24.2\Components\Bin\Framework.
Note
You can register the required assembly in the GAC instead of copying it to the application folder. Refer to the MSDN article for details.
Refresh the web page and see if there are other missing assemblies. Copy it from the Developer Workstation. Repeat the process until there are no errors reported concerning missing assemblies.
Note that if you are browsing your application from a remote workstation via the “http://<your_server_name>/mysolution” URL, the following brief error page that does not contain a missing assembly name may be displayed.
Web server error messages may contain information meant only for the developer and not for public access. That is why the display of unhandled error information is disabled in ISS, by default. Launch the browser and open your application at the web server locally, if possible. If you have no such access, edit your application Web.config file as shown below.
<system.web> <!-- ... --> <customErrors mode="Off">
This will give you a detailed error description at a remote browser (usually it will be a message about a missing assembly). For security reasons, it is recommended that you undo these changes in the Web.config file, after successful deployment.
Note
Only run-time assemblies from the Developer Workstation are required. Ensure that you do not accidentally copy design-time assemblies or XML files that are named like the run-time assemblies.
Finally, your application will display the following message.
It means that all assembly requirements are satisfied and the application now requires a proper connection string in its configuration file and access to its database. The Set Up the Database Connection lesson describes how to resolve this issue.
Note
If you experience any problems performing the steps in this lesson, refer to the Deployment Troubleshooting Guidelesson.
Now, your application needs a connection to a database to run properly. Proceed to the Set Up the Database Connection lesson to learn how to do this. To familiarize yourself with alternative deployment methods, refer to one of the following lessons.
- Xcopy Deployment of an ASP.NET Web Forms Application
- Setup Project Deployment of an ASP.NET Web Forms Application