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

使用Visual Studio发布Azure App Service(.NET后端)后页面跳转异常

排查Azure App Service发布后跳转至登录页的问题

Hey there, let's figure out why your .NET backend on Azure App Service is redirecting to the Microsoft login page instead of showing the expected "This mobile app is up and running" message. Here are the most likely causes and fixes to try:

  • Check App Service Authentication Settings
    Head to the Azure portal, find your App Service, and go to the Authentication tab. Chances are you've enabled App Service Authentication and set the action to "Require authentication"—this forces all unauthenticated requests to redirect to the login page. If your backend doesn't need mandatory auth, switch the action to "Allow anonymous requests (no action)", save the changes, and republish to test.

  • Review Project Authentication Configurations
    Look into your .NET project's appsettings.json, Program.cs, or Startup.cs for auth-related code. Did you add middleware like AddMicrosoftIdentityWebApp? Or set up a global [Authorize] filter? If global auth is the issue, either remove the global filter or add the [AllowAnonymous] attribute to your default home/health check route.

  • Verify Publish Configuration Auth Settings
    In Visual Studio's publish profile settings, check if you've checked the "Enable App Service Authentication" option. Sometimes publish syncs local auth configs to Azure automatically—if you don't need auth in production, uncheck this option before republishing.

  • Inspect Route Configurations
    Make sure your project has a default route (like /) that returns the expected page, and this route isn't decorated with [Authorize]. If the default route requires authorization, accessing it will naturally trigger a login redirect. You can temporarily add [AllowAnonymous] to the default controller/action to test this.

  • Check App Service Logs
    Turn on Log Stream in your App Service or download log files. The logs might show exactly which component is triggering the auth redirect, helping you pinpoint the root cause quickly.


内容的提问来源于stack exchange,提问作者Creepin

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 03:31:14