This guide shows how to put an ASP.NET Web Forms, MVC 5 or Web API 2 site built on .NET Framework (up to 4.8) onto FimuroHost Windows Hosting. The key idea: you upload the published output of your project, not the project source folder.
If your project is ASP.NET Core or .NET 5 and later, read Can I Run ASP.NET Core or .NET 8 on Windows Hosting? first.
Before you start
- Visual Studio 2022 (or later) with your project building without errors.
- Your Windows Hosting plan active, and the app pool set to v4.0, Integrated (see How to Choose the ASP.NET Version).
- If the site uses a database: an MS SQL database created in StackCP and its details to hand.
- FTP unlocked in StackCP, and an FTP client such as FileZilla.
Step 1: Prepare web.config for production
Make sure the live site doesn't run in debug mode. Debug builds are slower and show code details in error pages. Either edit Web.Release.config (a config transform applied when you publish in Release) or set these values directly:
<configuration> <system.web> <compilation debug="false" targetFramework="4.8" /> <httpRuntime targetFramework="4.8" /> <customErrors mode="RemoteOnly" defaultRedirect="~/Error" /> </system.web> </configuration>
A typical transform in Web.Release.config that swaps in the live connection string looks like this:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <connectionStrings> <add name="DefaultConnection" connectionString="Server=mssql.stackcp.com;Database=YOURDB;User Id=YOURUSER;Password=YOURPASSWORD;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" /> </connectionStrings> <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> </system.web> </configuration>
Copy the real server name, database name and username from StackCP; see Create an MS SQL Database and Connection Strings.
Step 2: Publish to a local folder
- In Visual Studio, right-click the web project and choose Publish.
- Choose Folder as the target and pick an empty folder, e.g.
C:\Publish\MySite. - Open Show all settings (or the pencil icon) and set Configuration to Release. Tick Delete all existing files prior to publish.
- Click Publish.
The folder now contains exactly what the server needs. For an MVC site you will typically see:
bin\ <- your DLLs and their dependencies Content\ <- CSS Scripts\ <- JavaScript Views\ <- .cshtml files Global.asax Web.config favicon.ico
There should be no .cs files, no obj folder and no .csproj. Web Forms sites built as a Web Site project (not a Web Application) are the exception: they compile on the server, so their App_Code folder and code-behind files are uploaded too.
You can also publish straight from Visual Studio over FTP. See Publish from Visual Studio to Windows Hosting.
Step 3: Upload the files
- Connect with FileZilla using the host, username and password from FTP Details in StackCP.
- Open the web root (normally
public_html). - Upload the contents of your publish folder, so
Web.configandbinsit directly in the web root. - Wait for the queue to finish with no failed transfers. A half-uploaded
binfolder causes “Could not load file or assembly” errors.
Updating a live site without errors
When you upload new DLLs, the site restarts and visitors may briefly see errors. To show a tidy maintenance page instead, upload a file called app_offline.htm to the web root first. While it exists, ASP.NET serves that page for every request. Upload your changes, then delete app_offline.htm.
Step 4: Create or import the database
If you use Entity Framework Code First migrations, you can generate a SQL script locally with Update-Database -Script (EF6) and run it against the hosted database in SQL Server Management Studio. To copy an existing local database, see Import and Export an MS SQL Database.
Step 5: Test
- Open the site on its preview address (
http://…stackstaging.com) or on your domain. - Click through pages that read from the database, submit forms, log in and upload a file if the site allows it.
- If you get a generic error page, temporarily turn on detailed errors as described in Classic ASP: Parent Paths and Showing Detailed Errors (the same
web.configsettings work for ASP.NET), then switch them off again.
Common problems
- Parser Error: Could not load type ‘MySite.Global’. The
binfolder is missing or in the wrong place. It must be directly under the web root. - Login fails for user. Wrong database username or password in the connection string, or you're using
Integrated Security=True. Shared hosting needs SQL Server authentication with a username and password. - Works locally, 404 on the server for MVC routes. Check the app pool is v4.0 and Integrated.
- Roslyn / csc.exe errors. Projects using the
Microsoft.CodeDom.Providers.DotNetCompilerPlatformpackage need thebin\roslynfolder. Make sure it was published and uploaded.
Need help?
If something doesn't work as described, open a support ticket from your client area or message us on WhatsApp at 01818160926. Tell us your domain name and the exact error message, and we will take it from there.
Categories
Written by
FimuroHost Team
Technical Writer