Asp.Net Core 2.0 Web应用程序的静态文件提供404

编程入门 行业动态 更新时间:2024-10-12 14:20:14
本文介绍了Asp.Net Core 2.0 Web应用程序的静态文件提供404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试从Web服务器(asp core 2.0)获取自定义扩展名静态文件.

I try to get custom-extension static files from my web-server (asp core 2.0).

我尝试下一个:

public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.AddDirectoryBrowser(); // just to see that I have this files } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseStaticFiles(); app.UseDirectoryBrowser(); } }

因此,我可以在文件夹中看到我的文件,但是我找不到它-它抛出404:

So, I can see my files at folders but I can't get it - it throw 404:

当我单击它时:什么也没发生,我得到了404.

And when I click on it: nothing happened and I got 404.

已更新为Evk:

我将static_json.json文件添加到src文件夹中的静态文件中,并按预期得到了它:

I added static_json.json file to static files at src folder and it get it as expected:

谢谢您的帮助!

推荐答案

我不确定,但是您的扩展名似乎被IIS设置拒绝了,可以直接作为静态资源进行访问.请为web.config尝试以下操作:

I am not sure, but it looks like your extension is denied by IIS settings to access directly as a static resource. Please, try this for the web.config:

<configuration> <system.webServer> <security> <requestFiltering> <fileExtensions> <add fileExtension=".appinstaller" allowed="true" /> </fileExtensions> </requestFiltering> </security> </system.webServer> </configuration>

还要检查请求过滤.查看更多信息: 如何拒绝对特定文件名的访问扩展名

Also check request filtering. See more information: How to deny access to a specific file name extension

更多推荐

Asp.Net Core 2.0 Web应用程序的静态文件提供404

本文发布于:2023-11-14 04:06:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586169.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:静态   应用程序   文件   Core   Net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!