【发布时间】:2010-03-10 03:42:57
【问题描述】:
如何保护 Rss 供稿以供私人查看?
【问题讨论】:
标签: asp.net asp.net-mvc security rss feed
如何保护 Rss 供稿以供私人查看?
【问题讨论】:
标签: asp.net asp.net-mvc security rss feed
您可以像保护任何其他文件一样通过 web.config 保护提要。大致如下:
<configuration>
<system.web>
<authentication mode="Forms">
<forms name=".AUTH" loginUrl="login.aspx" protection="All" timeout="60">
<credentials passwordFormat="MD5">
<user name="admin" password="" />
</credentials>
</forms>
</authentication>
<authorization>
<allow users="?" />
<allow users="*" />
</authorization>
</system.web>
<location path="feed.xml">
<system.web>
<authorization>
<allow users="admin" />
<deny users="*" />
</authorization>
</system.web>
</location>
</configuration>
【讨论】:
如果您有控制器操作并使用内置授权,则使用[Authorize] 属性装饰操作结果:
[Authorize (Users="List of users", Roles="List of roles")]
RssActionResult RssFeed(params)
{
}
【讨论】: