Here is a simple overview of my directory layout for my views:
Project
Issues
I am using forms authentication to deny access to all unauthenticated users, that works fine. However, I want to be able to grant access to the RSS views to everyone (so they can subscribe via google reader and stuff)
I understand that you can grant access to pages by adding the following page to your web.config
<location path="TOURPAGE.aspx">
<system.web>
<authorization>
<allow users="*" />
<allow users="?" />
</authorization>
</system.web>
However, how would I do this with my dynamically made URL's, such as:
Issues/RSS/chrisj
EDIT
Some answers I thought had fixed it, but:
It seems that, in my case at least, you still need the authentication cookie in order to see the page. You can be logged out and view it, so long as you have the cookie.
That is no good to me, I need the page to be completely public, as it is an RSS feed.
Forget about the <location><allow /><deny /> stuff... sounds like you need to use the [Authorize] attribute on your actions.
Check out these pages for more info: http://www.asp.net/learn/mvc/tutorial-17-cs.aspx http://www.pnpguidance.net/post/ASPNETMVCFrameworkPreview4HandleErrorAuthorizeOutputCacheActionFilterAttributes.aspx
Also, the attribute can be applied at the controller level as well, so you don't have to put it on each individual action.
This was actually much simpler than I thought. Seems .net is quite clever, I tried the following:
<location path="Issues/RSS">
<system.web>
<authorization>
<allow users="*" />
<allow users="?" />
</authorization>
</system.web>
And it worked :)
<location path="/Issues/RSS/">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
EDIT: The reason this works by the way, is because .NET is assuming that URL goes to a directory, and this location tag above says "anything in the 'Issues/RSS' directory is safe :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With