0
votes

We just moved our AngularJS application to .NET 6 and everything is working as expected, however every time we deploy the application to Azure App Service using Azure CI-CD Pipeline, we keep getting HTTP Error Code 500, Upon restart the App Service, it start to work again.

Below is the exception Details.

2022-07-26 18:43:18.397 +00:00 [Information] Microsoft.AspNetCore.Hosting.Diagnostics: Request starting HTTP/1.1 GET http://YOUR_WEBSITE_NAME.azurewebsites.net/ - -
2022-07-26 18:43:18.413 +00:00 [Error] Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware: An unhandled exception has occurred while executing the request.
System.InvalidOperationException: Using ExpandEndpoint requires that the replaced endpoint have a unique priority. The following endpoints were found with the same priority:
/Index
/Index
/Index
   at Microsoft.AspNetCore.Routing.Matching.CandidateSet.ValidateUniqueScore(Int32 index)
   at Microsoft.AspNetCore.Routing.Matching.CandidateSet.ExpandEndpoint(Int32 index, IReadOnlyList`1 endpoints, IComparer`1 comparer)
   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DynamicPageEndpointMatcherPolicy.ApplyAsync(HttpContext httpContext, CandidateSet candidates)
   at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet)
   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|8_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

Startup.cs

public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddMvc()
                .AddRazorPagesOptions(options =>
                {
                    // Match all routes to the index so we can handle routing client-side.
                    options.Conventions.AddPageRoute("/index", "{*url}");
                });
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseStaticFiles();

            app.UseRouting();
             

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
                endpoints.MapFallbackToPage("/Index");
   
            });

        }
    }