简体   繁体   English

限制下载到经过身份验证的用户-IIS,Asp.NET MVC

[英]Restrict downloads to authenticated users - IIS, Asp.NET MVC

I have two virtual directories under my site in IIS 7.5. 在IIS 7.5中,我的站点下有两个虚拟目录。

Unauthenticated users should not be allowed to access these files. 未经身份验证的用户不应被允许访问这些文件。

We are using ASP.NET Identity for authentication for the site if this has any bearing on the answer. 如果答案与答案有关,我们将使用ASP.NET Identity对该网站进行身份验证。

A lot of answers/googling seem to point towards using forms authentication in web.config, but As far as i know, ASP.NET Identity doesn't use this. 很多答案/搜索似乎都指向在web.config中使用表单身份验证,但是据我所知,ASP.NET Identity并未使用它。

How would i go about doing this? 我将如何去做?

EDIT: 编辑:

Some more info. 一些更多的信息。 These two virtual directories are set up in IIS with a specific user in the Physical Path Credentials. 这两个虚拟目录是在IIS中使用“物理路径凭据”中的特定用户设置的。

In your virtual directory, you need create a web.config file with this content: 在您的虚拟目录中,您需要使用以下内容创建一个web.config文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.web>
        <authorization>
            <deny users="?"/>
        </authorization>
    </system.web >
    <appSettings>
    </appSettings>
</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM