specify masterpage of subdirectory pages in web.config - asp.net

I know its possible to specify the masterpage of all pages using the pages element of the web.config but is it possible to specify that for all the pages under /foo/ that they should have a certain master page, and specify this in the root web.config.
I know this can probably be achieved by putting another web.config in the subdirectories that I want that specific masterpage to override but if possible I'd like to keep all of it in the one spot as when we change one section master page we are most likely going to be changing a few of them.

Try to add location element in the roor web config file with configuration specific for the subdirectory. location Element (ASP.NET Settings Schema)

Related

ASP classic include files in parent directory with plesk on godaddy

I know that you need to enable parent paths in order to include files in a parent directory, however I have no way of enabling this property on godaddy's plesk hosting. Is there any way around this or do I just need to upload the include files into each and every directory on my site.
The idea of the include files was that I would have less that needed maintaining, and if I need to upload them into every folder then I certainly don't have less to maintain.
Thank you for the help.
You can include files that are "higher up" in the folder hierarchy, you just can't use the file="../../" syntax. Instead, use "virtual" instead of "file" and specify the full path relative to the site's root:
<!-- #include virtual="/path/to/includes/filename.inc" -->
This has the added advantage of always being the same path, regardless of where you're including it, so you can copy & paste to your heart's content.
Of course, this will require editing every page that has includes in it, but since you were going to do that anyway, I gather this is not an issue.
Here is the way to allow parent path in plesk shared hosting, for example: godaddy
Go to Virtual Directories
Find Directory Properties under Tools section, click on it
Tick Allow to use parent paths checkbox under Application settings section
Hope this helps.

Setting folder default page in aspnet

My question is really simple. I have a Web application with multiple sub-folders and there's no Default.aspx page in any of these.
How do I set the default page in each of these folders so users can type /folder instead of /folder/login.aspx?
Can this be done through the web.config file?
Should I just rename the file in each folder to Default.aspx?
Thanks!
There is a default document section for web.config, and you can even put a web.config in each folder, and inside that config just have the default document set.
There's a Default Document icon in the IIS section of your websites configuration panel. Open that up and you can add login.aspx to the list.

asp.net location tag not working

We have an application that is making use of the location tag in the web.config file at the machine level - meaning like C:\Windows\Microsoft.NET\Framework\v2.0...\CONFIG\web.config, the one that applies to the whole server - this application has lots of virtual directories under it and for each one there is a
<location path="IIS Web App Name\CustomerA">...
This seems to work ok for that app. But then we have a second app on the same server, and I'd like to add location tags to that app's web.config file - meaning the local web.config file in the app's directory - and have each one of them specify a location tag in a similar way.
Is this possible? Because it doesn't seem to work. I've tried:
<location path="My IIS App Name\CustomerA"> ...
and
<location path="CustomerA"> ...
and neither seem to work. I just need this location node to contain 1 node.
Is there maybe some
It would have to be a file or folder within that virtual. So I could set rules for "default.aspx" in the same root as the config file, or manage a folder like "Content" for the Content folder. I've done this successfully.
Or, put another config file in the folder you want to set custom rules for, and define rules there that will override the main...
HTH.

Is it possbile in ASP.NET to deny access to a number of directories using single directive?

Is it possible to deny access not only per directory using directive <location> but a to a number of directories at one time?
Or I have to use every time <location> for each directory?
No, I don't think that this is possible using the location tags. It of course applies to all subdirectories, but I don't think that's what you're referring to.
You could of course write your own handler, or have a page base class that all pages you want to protect inherit from.

Is it possible to completely negate a "higher" web.config in a subfolder?

Is it possible to completely negate a web.config in a subfolder?
Obviously, I have a web.config in the root.
If I have a subfolder called "MyApp", can I write a bunch of code in there and have it run without any reference to the web.config at root? It would have its own web.config, and wouldn't even reference the "higher" web.config in root.
What I'm looking for is complete App isolation. I'd like to be able to write an app in a subfolder of an existing site, which ignores the entire web.config hierarchy above it -- the app would an island all to itself.
I know I can use the "clear" element, but is that the best way? Just put a "clear" under every top level element? Just wondering if there's another way.
Duplicate of Will a child application inherit from its parent web.config?
On the web.config file in the root directory, wrap the <system.web> element with the following element: <location path="." inheritInChildApplications="false"></location>
Check out this link for a reference:
http://www.jaylee.org/post/2008/03/Prevent-ASPNET-webconfig-inheritance-and-inheritInChildApplications-attribute.aspx
Yes, you have to clear those sections want to override. Thinking about it a bit more, this makes sense, as the only way to clear everything might make it very hard to work out what to clear it to. Clear normally resets everything, including the root web.configs in the web.configs and machine.config defined in the frameworks /config folder on your server.
Note that you'll also lose access to the /bin folder, /app_code folder, etc. This may or may not be what you want.
Whether you can create sub-applications with your host is another matter to consider as well.
No. By design for shared hosting and simplicity sake.
IIS7 changes that a little by allowing the configs to be explicitly locked/unlocked.
It sounds more like you should create a virtual directory that is another application root entirely.
I've just come across this issue in my work and my solution was to create a new website, instead of trying to nest my application under the existing website. I kept the domain mapping the same for the new application (i.e. www.mysite.com ) but changed the port number/mapping.
As a result I can use my new app on www.mysite.com:88 and didn't have to use a subdomain.
The caveat here is that my application is a web service so having to specify the port number in the URL was a possibility for me. It might not be an option for you but I thought I would post this incase it helps someone in my situation.
The <location path="." inheritInChildApplications="false"></location> solution wasn't an option for me as the inheritInChildApplications doesn't seem to exist before ASP.Net Framework 4.0?

Resources