Web.config file not inheriting ALL parent Web.config settings (elmah) - asp.net

I have a few applications that are set up using elmah for error handling. I recently read that Web.config files inherit from parent applications/directories, and decided to test it so that I can change elmah's settings in one place (since all the current Web.configs are identical when it comes to the elmah configuration). After creating a virtual directory in IIS7, nesting all my applications under it, and creating a stand-alone Web.config file in the physical folder, I tried testing it.
After removing the elmah specific configurations from one of the applications, I found that elmah stops working altogether. Just to see if it was something I did wrong, I created a connection string in the parent Web.config file, then called the connection string through code in the application. No issues. Inheritance was working fine. I tried adding all the elmah specific configurations back in, and removing them one at a time, but it kept complaining every time I removed something.
The question I have is:
Can only certain settings be inherited from the parent Web.config?
If not, am I just not comprehending how inheritance works with nested Web-configs?
I wanted to ask if it's an issue with me before I ask about it on the elmah site.

You should check this answer, it will maybe help you.
Also, in your child web.config, make sure that you do copy the configsections for Elmah (or make sure they are properly inherited). Otherwise, the elmah sections in your child web.config might not work (not entirely sure about that though)

Related

Rich text editor with standalone apps under Sitecore web root

I've been trying to configure a standalone ASP.Net application beneath a Sitecore web root (more or less as outlined here: http://sitecoreblog.alexshyba.com/2009/05/standalone-apps-under-sitecore-web-root.html). It's almost successful in that the virtual directory runs, but in the /sitecore folder, the rich text editor no longer works. Here is the error it throws:
'~/Telerik.Web.UI.WebResource.axd' is missing in web.config. RadScriptManager requires a HttpHandler registration in web.config. Please, use the control Smart Tag to add the handler automatically, or see the help for more information: Controls > RadScriptManager.
It works fine when I revert back to the original configuration.
Does anyone know how to properly configure this?
More info (1):
So, in the sitecore web.config, at the root, I added:
location path="." inheritInChildApplications="false" above the sitecore, system.webserver, and system.web nodes. The non-sitecore app I was attempting to run works great when I do this, but it somehow creates the Telerik.Web.UI.WebResource.axd I mention above, in the /sitecore folder, mostly when using the rich text box.
More info (2): This happens when I make these changes to the web.config in the sitecore root. While attempting to fix the problem, I did make a few changes to the web.config files in the /sitecore folder (including deleting them). but it made no difference. I've since restored the /sitecore folder to it's original configuration.
The standalone app is running as a separate app, immediately off the root, so: http://mysitecoresite/mystandaloneapp.
I had the same problem. After much searching, this fixed it for me (using v7.2 rev 140228): http://docs.telerik.com/devtools/aspnet-ajax/controls/scriptmanager/troubleshooting/overview#telerikwebuiwebresourceaxd-is-missing-in-webconfig-radscriptmanager-requires-a-httphandler-registration-in-webconfig
You have to set the EnableHandlerDetection property where it is declared on the Sitecore .aspx pages. I found it on EditorWindow.aspx and EditorPage.aspx.
<telerik:RadScriptManager ID="RadScriptManager" runat="server" EnableHandlerDetection="false"></telerik:RadScriptManager>

ASP.NET Changes to externally linked config file cause IIS application to restart?

I have a config file linked from web.config e.g.
<features configSource="feature.config" />
When I make changes to the "feature.config" file the IIS application appears to restart, is this expected behaviour?
Yes, this is expected behaviour by default as typically any changes made to the web.config will cause an application restart however this can be overridden for app.config files. From the msdn:
Saving a Web.config file restarts the
application. You can alternatively use
the configSource attribute of
individual section elements to point
to a secondary configuration file that
does not cause an application restart
when it is changed.
Although you have moved some of your configurations into a linked config file they are still effectively part of your web.config file and any changes made there will have the same effect as if you made the change directly in the web.config file itself. However you can specify a section to not restart the application on change by using the restartOnExternalChanges attribute in the section definition. See here and here for further details. However, according to the documentation this is not valid for ASP.NET applications which makes the above statement a little misleading.

Changing customErrors in web.config semi-dynamically

The basic idea is we have a test enviroment which mimics Production so customErrors="RemoteOnly". We just built a test harness that runs against the Test enviroment and detects breaks. We would like it to be able to pull back the detailed error. But we don't want to turn customErrors="On" because then it doesn't mimic Production.
I've looked around and thought a lot, and everything I've come up with isn't possible. Am I wrong about any of these points?
We can't turn customErrors on at runtime because when you call configuration.Save() - it writes the web.config to disk and now it's Off for every request.
We can't symlink the files into a new top level directory with it's own web.config because we're on windows and subversion on windows doesn't do symlinks.
We can't use URL-Mapping to make an empty folder dir2 with its own web.config and make the files in dir1 appear to be in dir2 - the web.config doesn't apply
We can't copy all the aspx files into dir2 with it's own web.config because none of the links would be consistent and it's a horrible hacky solution.
We can't change customErrors in web.config based on hostname (e.g. add another dns entry to the test server) because it's not possible/supported
We can't do any virtual directory shenanigans to make it work.
If I'm not, is there a way to accomplish what I'm trying to do? Turn on customErrors site-wide under certain circumstances (dns name or even a querystring value)?
If you have customErrors="On" or "remoteOnly" the error detail doesnt go away right? I mean you can still access it and log it to another source using your custom error page.
Why dont you just have your custom error page in production log the information somewhere your harness can access it, like a message queue or App event log? When the harness comes across a break it just has to be smart enough to do a lookup in the right place for the full error info.
Another thing to consider anyway.

Multiple Web.Config files in ASP.NET web application

I have an ASP.NET web application where i am having multiple subrirectories in the root folder.in my root web.config, i have sessionMode as "StateServer" . So in one page of my subdirectory, i am not able to do serialization. If i change the SessionMode method to "InProc" , it will work fine. I want to maintain the web.config file in the root directory as it is.So i am planning about having another web.config file in sub directory.Can anyone tell me how to do this ?
Thanks in advance
While you can have a Web.config in every subdirectory not all settings are allowed at all levels.
And SessionMode is one setting that can only be made in the application-root.
You can just place a new web.config file in the sub-directory and ASP.NET will override any settings you change in that directory.
If you mark the class that is being put in the Session with the [Serializable] attribute, it can usually be used in an StateServer setup.
Just put another web.config in the subdirectory. ASP.NET allows for that, and I have several areas on my website where the web.config contains values specifically for that "application" specifically.
That said:
1) Are you sure it's a good idea to maintain state in two different ways? It would probably be better to figure out how to make your session state serializable or get rid of using session state altogether.
2) All those web.config files can get tough to maintain if you're not careful about what values you put in each.

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