It is a Razor Pages Project. Any way, no matter Razor Pages or MVC project, the static file should be located in the wwwroot
folder by default. Then you could easily access it.
If you place the Impresorashtml.html
in the root of the wwwroot
folder. You can access it by using code below:
<a href="/Impresorashtml.html" target="_blank"> Impresoras </a>
If you place the Impresorashtml.html
in the sub folder of the wwwroot
folder. You can access it by using code like below:
<a href="/html/Impresorashtml.html" target="_blank"> Impresoras </a>
If you want to serve files outside of wwwroot
like what you did(place it in the Pages
folder), you need configure the static file middleware as follows:
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(builder.Environment.ContentRootPath, "Pages")),
RequestPath = "/StaticFiles"
});
Then access it by using the code below:
<a href="/StaticFiles/Impresorashtml.html" target="_blank"> Impresorashtml</a>
Reference:
Serve files outside of web root