求部署ASP.NET Core 2.0 + Angular 5至A2 Hosting Windows共享主机的分步指南
Got it, here's a tailored step-by-step deployment guide for your ASP.NET Core + Angular admin app on A2 Hosting's Windows shared hosting—all actionable steps right here, no external links needed:
1. Prepare Your ASP.NET Core Backend for Local Publishing
- Open your ASP.NET Core project in Visual Studio (or your preferred IDE).
- Right-click the project → Select Publish, then choose the Folder target. Set a local output path (e.g.,
C:\Published\AdminAppBackend) and ensure the build configuration is set to Release. - Once published, verify the output folder contains core files: your app’s
.dll,web.config,wwwrootdirectory, and any dependent libraries. - Tweak the
web.configfor A2’s environment: Ensure theaspNetCorenode uses InProcess hosting (A2 supports this for better performance) and disables unnecessary logging:<aspNetCore processPath="dotnet" arguments=".\YourAdminApp.dll" stdoutLogEnabled="false" hostingModel="InProcess" />
2. Package Your Angular Frontend for Production
- Open a command line in your Angular project’s root directory.
- Run the production build command:
This generates ang build --configuration productiondist/your-angular-appfolder with minified, production-ready frontend files. - Copy all files from the
distfolder into thewwwrootdirectory of your published ASP.NET Core backend. This lets your backend serve the frontend static files directly, simplifying deployment.
3. Upload Your Combined App to A2 Hosting
- Log into your A2 Hosting cPanel dashboard.
- Use either the File Manager tool or an FTP client (like FileZilla) to connect to your Windows shared host.
- Create a dedicated subdirectory for your admin app (e.g.,
/public_html/admin-app) to keep it isolated from other site content. - Upload every file and folder from your published ASP.NET Core directory (including the updated
wwwrootwith Angular files) to this new subdirectory.
4. Configure A2 Hosting Environment Settings
- In cPanel, locate the ASP.NET Core Settings tool (or labeled
.NET Core Managementdepending on your cPanel theme). - Select the subdirectory where you uploaded your app, then set the .NET Core Version to match the version you used to publish your backend (e.g., .NET 6.0 or .NET 7.0).
- Navigate to Application Pools in cPanel: Assign your app to an application pool with Integrated Pipeline Mode and ensure the .NET version matches your app. Leave 32-bit applications disabled unless your app specifically requires it.
- Double-check file permissions: Right-click your app’s directory in File Manager → Change Permissions. Set permissions to
755for folders and644for files (A2 typically auto-configures this, but it’s good to verify).
5. Test Your Deployed App
- Navigate to your app’s URL (e.g.,
https://your-domain.com/admin-app) in a browser. - Verify the Angular frontend loads correctly, and test backend API calls to ensure connectivity.
- If you encounter SPA routing 404 errors, confirm your ASP.NET Core
Program.cs(orStartup.csfor older versions) includes the SPA fallback route:
This ensures all frontend route requests are directed to Angular’sapp.MapFallbackToFile("index.html");index.htmlinstead of returning a 404.
内容的提问来源于stack exchange,提问作者Rizwan Ali Sabir
相关产品推荐
相关产品推荐

