简体   繁体   中英

Deploying ASP.NET Core App to Azure results in blank pages

I have a free tier Azure account. I have an ASP.NET Core MVC project, committed to GitHub, which I have developed in C# on Visual Studio for Mac build 8.10.23 (Community). Everything works perfectly when running locally. I wanted to deploy this to Azure, so it's publically available for testing.

I have set up continuous integration from my GitHub account to my Azure application. The build and deploy process both run and succeed whenever I commit.

Problem : When I access my application URL, I get only blank pages. It's as if the views will not render. I am able to access files in /wwwroot (by manually typing the website URL and something like /img/intro.png) and they display, so I know the web server is serving files. But it does not seem like ASP.NET Core is operating correctly, and I'm not able to see any errors in Kudu.

Website URL: https://legendary-mud.azurewebsites.net/ GitHub URL: https://github.com/Usualdosage/Legendary

Any ideas are greatly appreciated.

The reason for this problem is that your middleware has no next method in pipline and is interrupted.

You need to change your Server.cs file like below.

// <copyright file="Server.cs" company="Legendary">
//  Copyright © 2021 Legendary
//  All rights are reserved. Reproduction or transmission in whole or
//  in part, in any form or by any means, electronic, mechanical or
//  otherwise, is prohibited without the prior written consent of
//  the copyright owner.
// </copyright>

namespace Legendary.Networking
{
    using System.Threading.Tasks;
    using Legendary.Core.Contracts;
    using Legendary.Data.Contracts;
    using Legendary.Engine.Contracts;
    using Legendary.Networking.Contracts;
    using Microsoft.AspNetCore.Http;

    /// <summary>
    /// Server concrete implementation.
    /// </summary>
    public class Server : IServer
    {
        private readonly Engine.Engine engine;
        private readonly RequestDelegate _requestDelegate;
        /// <summary>
        /// Initializes a new instance of the <see cref="Server"/> class.
        /// </summary>
        /// <param name="requestDelegate">The request delegate.</param>
        /// <param name="logger">The logger.</param>
        /// <param name="connection">The database connection.</param>
        /// <param name="dataService">The data service.</param>
        /// <param name="apiClient">The API client.</param>
        public Server(RequestDelegate requestDelegate, ILogger logger, IDBConnection connection, IDataService dataService, IApiClient apiClient)
        {
            _requestDelegate = requestDelegate;
            logger.Info("Legendary server is starting up...");
            this.engine = new Engine.Engine(_requestDelegate, logger, connection, dataService, apiClient);
            this.engine.Start();
        }

        /// <inheritdoc/>
        public async Task Invoke(HttpContext context)
        {
            // TO-DO: Handle IP ban list
            await this.engine.Invoke(context);
            // Call the next delegate/middleware in the pipeline.
            await _requestDelegate(context);
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM