Last post Jan 22, 2007 03:39 AM by bipro
Jan 05, 2007 02:28 AM|will2007|LINK
First, let me state for the record that I am not an expert when it comes to asp.net and iis.
I have a default web site that has a web.config file. Also, on the same server I have one other web site and a couple of web services.
Recently, I made a change to the default site's web.config file and it works fine for the default site, but it causes problems/errors with the other site and the web services. The other web site and the web services have their own web.config files. I thought
that if a site had its own web.config, it would ignore the higher level one. Is that not correct?
Thanks for any help or suggestions.
Jan 05, 2007 04:11 AM|XIII|LINK
I thought that if a site had its own web.config, it would ignore the higher level one. Is that not correct?
actually no. The settings in a web.config file override the settings in a higher leveled web.config and ultimately the default settings of the machine.config file. So when you change something at a higher level that could affect more than you wish for. So
in your case you must decide if you want to keep the changes in the default sites settings and override them again in the web.config files of the webservices or you can specify the settings in the web.config of your web application.
Another option would be to use the
<location> element in a web.config at a higher level and specify the path attribute to only have those settings for a specific site or webform.
Jan 05, 2007 10:08 AM|will2007|LINK
Thanks alot for the help and explanation. Would I be able to add a dummy <httphandler> section to my other web.config files and have that override the httphandler in the default web.config?
I checked out the <location> element last night...but it did not work for me.
Jan 05, 2007 10:57 AMfirstname.lastname@example.org|LINK
The <location> element doesn't work for everything but it is a great way to separate sites if you need to restrict someone administering lower levels. Better is to have all separate sites and applications in a parallel folder structure if you don't want
inheritance. In general, I only have web.configs at a lower level with the sections that need to be modified for a specific app, and I really only do this in rare cases.
Of course this assumes you don't have a root application, if you need one this structure doesn't work that well.
The "dummy" section idea works, and is probably the way you'll need to go for what you describe here.
Jan 05, 2007 11:25 AM|will2007|LINK
In regards to the <location> section...is there a good article explaining how it "should" work? I have tried and it just doesn't work for me...which means I am probably not putting in the correct attributes or references or something.
And...for the dummy section, could I just do something like:
Jan 05, 2007 12:49 PM|will2007|LINK
I added a dummy <httpHandlers> section and it has no effect at all. The error still occurs with the other web sites and web services.
Here is what I added:
<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory, System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Is there any way to override the <httpHandlers> section coming from my default web site?
Jan 05, 2007 01:24 PMemail@example.com|LINK
You can look at:
Jan 05, 2007 02:14 PM|will2007|LINK
Thanks for the links. I had already read a few of them...but the one that I had not seen helped alot. It was the Blog that explained how the 1.1 web.config stuff...using the Remove element is broken, but that it works fine in 2.0.
Unfortunately, I am currently dealing with 1.1....so instead of all these various work-arounds, I will just have to change the way we're working with a barcode control that uses httpHandlers.
thanks for the info and help
Jan 05, 2007 03:51 PMfirstname.lastname@example.org|LINK
That explains your problem then, I was assuming 2.0 and couldn't figure out why it wasn't working as it should.
Jan 22, 2007 03:39 AM|bipro|LINK
i had this exact same problem. The only way i managed to resolve this was specifically remove exact same httphandler so, for example if you have the following in your root web.config:
<add verb="GET" path="blah.ext" type="SomeNamespace.SomeType" />
if you add the following to your web.config for the sub-application the problem is gone.
<remove verb="GET" path="blah.ext" />
probably not the most elegant solution - but it works. If you use this application as a root application as well as a sub application you'll have to do an add before the remove with a blank type. i.e.
<add verb="GET" path="blah.ext" type="" />
<remove verb="GET" path="blah.ext" />
Mark the thread to resolved if this solves your problem, but let us know either way.
I hope this helps.