Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

like image 448
This is it Avatar asked Dec 20 '10 15:12

This is it


People also ask

What is location path in Web config?

The path attribute defines the site or virtual directory that the configuration settings cover. To specify that the settings in the <location> element apply to the default Web site, set the path attribute to Default Web Site .

How do I add file path to Web config?

Answers. later you can access the file path using: string filePath = ConfigurationManager. AppSettings["Path"].

Can we use multiple Web config files in a single application?

Yes you can have two web. config files in application.

Where is the IIS Web config file located?

config files. The configuration files for IIS 7 and later are located in your %WinDir%\System32\Inetsrv\Config folder, and the primary configuration files are: ApplicationHost. config - This configuration file stores the settings for all your Web sites and applications.


2 Answers

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.

like image 161
hunter Avatar answered Oct 31 '22 16:10

hunter


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.

like image 41
Deniz Dogan Avatar answered Oct 31 '22 14:10

Deniz Dogan