This is it
This is it

Reputation: 789

Multiple paths in location element of web.config

How can I specify multiple paths in one location element in web.config?

<location path="Images">
    <system.web>
        <authorization>
            <allow users="?" />
        </authorization>
    </system.web>
</location>

We would like to add styles and images to location, e.g. <location path="images, styles">.

Is it possible to put multiple paths in location element (and how would I do that)?

Upvotes: 15

Views: 22097

Answers (2)

hunter
hunter

Reputation: 63522

You cannot do this unless they share the same root folder. I've been known to dump images/styles/javascript into a single folder like "_res" or "_system" and authorize that folder

More info on the location element: http://msdn.microsoft.com/en-us/library/b6x6shw7(v=vs.71).aspx

On the path attribute:

Specifies the resource that the contained configuration settings apply to. Using location with a missing path attribute applies the configuration settings to the current directory and all child directories. If location is used with no path attribute and allowOverride is False, configuration settings cannot be altered by Web.config files that are in child directories.

Upvotes: 14

Deniz Dogan
Deniz Dogan

Reputation: 26227

You must use one location element for each location that you want to control access to. The path can be a directory, which will make the rules apply to everything in that directory.

Upvotes: 2

Related Questions