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

Time:06-15

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.

CodePudding user response:

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);
        }
    }
}
  • Related