【发布时间】:2014-12-21 08:33:24
【问题描述】:
在等待解决我的类似问题 (Self-hosted Owin, static files and authentication) 时,我想使用 Asp.net Identity 保护 MVC 应用程序中提供静态文件的目录。 如何保护我的下载目录但仍保留 MVC 和 Identity 的所有优点?
【问题讨论】:
标签: asp.net-mvc-5 asp.net-identity-2
在等待解决我的类似问题 (Self-hosted Owin, static files and authentication) 时,我想使用 Asp.net Identity 保护 MVC 应用程序中提供静态文件的目录。 如何保护我的下载目录但仍保留 MVC 和 Identity 的所有优点?
【问题讨论】:
标签: asp.net-mvc-5 asp.net-identity-2
解决方案非常简单明了:只需添加具有所需授权的 Web.config。
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</configuration>
这也是我第一次立即尝试,但我忘记正确设置复制到输出目录属性。
【讨论】: