You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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.

1. First: Confirm Your Deployment Files Actually Uploaded Correctly

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, the wwwroot static 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.
2. Fix Your Web App's Startup Command

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 (replace YourProjectName with 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).
  • Save the settings and restart your Web App.
3. Validate Runtime and Environment Configurations

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 csproj file's TargetFramework value).
  • Go to Configuration > Application Settings, add or verify the ASPNETCORE_ENVIRONMENT setting:
    • Set it to Production (most common) or Development if you need debug logs (note: don't leave this as Development in production).
  • If your app uses appsettings.json configurations, ensure the correct environment-specific file (like appsettings.Production.json) was included in the deployment.
4. Check Application Logs for Hidden Errors

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/Application to download and review detailed log files.
5. Verify MVC Route and Default Page Setup

If your app starts but still shows the default page, double-check your MVC routing:

  • Ensure your Program.cs (or Startup.cs for 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 HomeController with an Index action, and the corresponding Views/Home/Index.cshtml view 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 22:48:17