views:

15

answers:

1

I have denied anonymous access to the entire application using the following Web.Config setting:

<authorization>
   <deny users="?" />
</authorization>

Then, for various paths, I have allowed anonymous access using Web.Config settings such as this:

<location path="Home/ShowLogin">
<system.web>
  <authorization>
    <allow users="*"/>
  </authorization>
</system.web>

I'd like to be able to determine during the processing of a given request whether the requested URL is to path that allows anonymous users or whether the request is to a path that denies anonymous users.

What is the most elegant way of determining this?

A: 

You can use the following code to get the collection of location elements:

Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
foreach (ConfigurationLocation location in config.Locations)
{
  // work with location object
}
Daniel
Very nice! Digging through the API of System.Configuration. I'm surprised how much is there....and how little I've been using of it.
bzarah