0

This is my startup.cs file:

using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNetCore.Builder;using Microsoft.AspNetCore.Hosting;using Microsoft.AspNetCore.Http;using Microsoft.Extensions.DependencyInjection;using Microsoft.Extensions.Hosting;

namespace TigerTix3.Web{public class Startup{public void ConfigureServices(IServiceCollection services){services.AddControllersWithViews();}

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        //app.UseDefaultFiles();
        app.UseRouting();
        app.UseStaticFiles();

        app.UseEndpoints(endpoints =>
        {

            endpoints.MapControllerRoute("Default",
                "/{controller}/{action}/{id?}",
                new { controller = "App", action = "Index" });


        });
    }
}

}

Right now, the website is displaying "This Page isn't working" because I commented out app.UseDefaultFiles. When I un-comment that out, it displays index.html instead of index.cshtml. Any help would be greatly appreciated.

I am new to C#, HTML, and Visual Studio so I am going off of my instructors instructions, but it appears that the instructions don't work. I am positive I followed them to the letter.

jazb
  • 5,498
  • 6
  • 37
  • 44
  • If you need to see my AppController.cs file or any other files let me know – Cole Fleishman Mar 30 '22 at 22:52
  • The `.UseDefaultFiles` middleware will ignore requests that `.UseRouting` has already mapped to an endpoint. (see https://github.com/dotnet/aspnetcore/blob/4c5a4db8937e083363c1ae7987842f00342a4838/src/Middleware/StaticFiles/src/DefaultFilesMiddleware.cs#L62) So just put `.UseRouting()` first. – Jeremy Lakeman Mar 31 '22 at 04:08
  • If i put userouting before usedefaultfiles the page does not load when I run. Just tried again, it does run, but index.html still displays instead of index.cshtml – Cole Fleishman Mar 31 '22 at 18:36

0 Answers0