0

I got a html file index.html that i want to link with my asp.net5 project.

I have tried to add the index.html in wwwroot and when I start the debug I go to localhost:port/index.html and it shows me nothing.

Can some one link to a documentation or explain how to do it?

PS: I use visual-studio.

Config code:

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app)
    {
        app.UseIISPlatformHandler();
        app.Run(async (context) =>
        {

            await context.Response.WriteAsync("test");
        });

    }

1 Answer 1

1

You have to tell the app that you want to use static files. You wouldn't need it in a Web Api 2.0 server for instance. So, this is not added by default. In your Startup.cs add app.UseStaticFiles(); to the Configure method.

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{    
    app.UseIISPlatformHandler();
    app.UseStaticFiles();
    app.UseMvc();
}
Sign up to request clarification or add additional context in comments.

3 Comments

Hello Thank you for response but i dont get use static files i only get app.UseIISPlatformHandler and app.UseMiddleware
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
add the dependencies in your project.json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.