P
P
Peter2018-05-18 19:50:43
ASP.NET
Peter, 2018-05-18 19:50:43

ASP Net Core. Why is index.html not showing up?

Good afternoon. Why might html pages added to the project's wwwroot folder not be displayed when run outside of Visual Studio? If you run the project from under the IDE, then the page is shown. If I run from the project folder through the console with the dotnet command, then Hello World is displayed on the screen.

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {

            app.UseDefaultFiles();
            app.UseStaticFiles();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World!!");
            });
        }

Here is the contents of the Configure method from the Startup class.
Moreover, there is no page even if I add index.html in the browser through a slash. I'm probably missing something but I can't figure out what exactly.
Thanks in advance for your replies.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2018-05-19
@yarosroman

app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World!!");
            });

But why is this? From VS, the project is hosted on IIS Express and it probably gives you statics normally, self hosted is obtained from under the console, and the above expression is triggered, which rewrites the entire server response. Take it away.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question