Azure发布ASP.NET Core Web App后无法显示项目内容求助
Hey there, let's troubleshoot this ASP.NET Core MVC deployment issue step by step—this is a super common gotcha with Azure Web Apps, so we’ll get your app showing up properly in no time.
The most basic (but often overlooked) check is making sure your published app files are in the right place on Azure:
- Head to your Web App in the Azure Portal, go to Advanced Tools (under Development Tools), then click Go to open Kudu.
- In Kudu, select Debug Console > PowerShell (for Windows App Service) or Bash (for Linux).
- Navigate to
site/wwwroot—this folder should contain your app's DLLs, thewwwrootstatic files folder,web.config(Windows only), and other deployment artifacts.- If you only see the default landing page files (like
hostingstart.html), your deployment didn't upload correctly. Double-check your deployment method:- If using Visual Studio Publish: Ensure you selected the correct Azure Web App target, and the publish profile is set to deploy the output of your build (not just project files).
- If using Zip Deploy: Make sure you zipped the contents of your local publish folder, not the folder itself. Zipping the folder will put all your app files inside a subfolder in
wwwroot, which Azure can't find.
- If you only see the default landing page files (like
Azure sometimes fails to auto-detect the correct startup command for ASP.NET Core apps, especially with newer SDK versions:
- Go to your Web App in Azure Portal, select Configuration > General Settings.
- Look for the Startup Command field:
- For Windows: Enter
dotnet YourProjectName.dll(replaceYourProjectNamewith the actual name of your main app DLL). - For Linux: Same command applies, but ensure the runtime stack in General Settings matches your project's .NET Core version (e.g., .NET 6 LTS).
- For Windows: Enter
- Save the settings and restart your Web App.
Mismatched runtime or environment settings can silently prevent your app from starting:
- In Configuration > General Settings, confirm the Stack is set to the correct .NET Core version (match what your project targets—check your
csprojfile'sTargetFrameworkvalue). - Go to Configuration > Application Settings, add or verify the
ASPNETCORE_ENVIRONMENTsetting:- Set it to
Production(most common) orDevelopmentif you need debug logs (note: don't leave this as Development in production).
- Set it to
- If your app uses appsettings.json configurations, ensure the correct environment-specific file (like
appsettings.Production.json) was included in the deployment.
The default landing page often means your app is failing to start—but Azure won't show the error by default. Enable logs to get the full picture:
- In your Web App, go to Monitoring > App Service Logs.
- Turn on Application Logging (Filesystem) and set the log level to Error or Information.
- Save the settings, then restart your app.
- View logs in two ways:
- Log Stream: Under Monitoring > Log Stream, watch real-time logs as your app tries to start—look for exceptions like missing dependencies, configuration errors, or port conflicts.
- Kudu Logs: Go back to Kudu, navigate to
site/wwwroot/LogFiles/Applicationto download and review detailed log files.
If your app starts but still shows the default page, double-check your MVC routing:
- Ensure your
Program.cs(orStartup.csfor older .NET versions) has the correct routing setup:// For .NET 6+ app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); - Confirm you have a
HomeControllerwith anIndexaction, and the correspondingViews/Home/Index.cshtmlview exists in your deployment. - If you're using static files as the default page, make sure
app.UseStaticFiles()is called before routing in your startup code.
Once you work through these steps, you should be able to spot the exact issue. If you find specific error messages or weird behavior in the logs, feel free to share more details and we can narrow it down further!
内容的提问来源于stack exchange,提问作者Farid Huseynov

