How can i secure the Rss feed for private viewing?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can secure the feed the same way you would any other file, via the web.config. Something along the lines of:
<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>
回答2:
If you have controller action and use builtin authorization then decorate action result with [Authorize]
attribute:
[Authorize (Users="List of users", Roles="List of roles")]
RssActionResult RssFeed(params)
{
}