10

My company has a website built in ASP.NET and targets .NET 3.5. It is too mangled and massive to be converted to .NET 4 in a timely manner. I am tasked with building a ticketing system. I want this ticketing system to be a completely separate application from the main application.

I added a directory to the website called "TicketingSystem", then in IIS I set this folder as an application, using an app pool that targets .net 4.0. I assumed this application would not be affected by the application above it, especially since it uses its own app pool, but it would seem it is being affected somehow. Navigating to this directory with my .net 4 web app in it generates this error:

http://www.chevtek.com/content/error.jpg

I covered the sensitive information like file paths and stuff, but the line that says config file has a path to the parent application's config file, not the config file of the .net 4 app. Is it not possible to nest a .net 4.0 app within a .net 3.5 app?

Edit

As requested here is a screenshot of the IIS directory structure.

http://www.chevtek.com/content/IISDirectoryStructure.jpg

halfer
  • 19,824
  • 17
  • 99
  • 186
CatDadCode
  • 58,507
  • 61
  • 212
  • 318
  • That seems like it should work. Can you post a screenshot of the folder browse list in IIS for the website? – mellamokb Feb 18 '11 at 20:49
  • Did you make sure to recycle your app pool etc? – Jimmy Feb 18 '11 at 20:53
  • @Chevex: why would it be a "conversion"? It should be compatible. How about take your QA system, "convert" to 4.0, run your automated tests, and see what happens? – John Saunders Feb 18 '11 at 20:53
  • This question has come up before; See my answer on this question: http://stackoverflow.com/questions/4315999/conflict-on-iis-7-5-with-web-config-when-mixing-different-versions-of-asp-net/4326115#4326115 – Chris Shaffer Feb 18 '11 at 20:55
  • I think you are misunderstanding john, their app is a mess. It can't be converted, they don't have automated tests. It is a giant nest of assemblies and things that have to stay in 3.5. Seriously, we can't go there. They botched this thing good. (before I got here) – CatDadCode Feb 18 '11 at 20:55
  • @John: Agreed. But from experience, Murphy's law applies. Anything that can go wrong, will go wrong. – mellamokb Feb 18 '11 at 20:56
  • @Chevex: Does it work if you run it as a separate application instead of a sub-app of the ToolBox project? – mellamokb Feb 18 '11 at 20:57
  • I agree with you guys, and trust me when I tell you that I have tried converting that beast to .net 4. It's not going to happen, not anytime soon. – CatDadCode Feb 18 '11 at 20:57
  • @Chevex: lack of tests is the factor that says "no". But then, they will _never_ have tests, will they? – John Saunders Feb 18 '11 at 20:57
  • @Chevex: what problems did you have with "conversion"? It's not supposed to _be_ a conversion at all. I'm not talking about switchint to VS2010 or targeting .NET 4.0. I mean just changing the parent app pool to .NET 4.0. – John Saunders Feb 18 '11 at 20:58
  • @mellamokb Yes, it does work if I run it as it's own website, or if I open that project in visual studio and use the visual studio web service to run it. – CatDadCode Feb 18 '11 at 20:58
  • @john, no they will never have tests. – CatDadCode Feb 18 '11 at 20:58
  • @John I told you not to go there, seriously. This is a large company and this application is enormous, you are only seeing a tiny tiny tiny snippet of the directory structure in that screen shot. It's not moving to .net 4.0 and that's that. – CatDadCode Feb 18 '11 at 20:59
  • @Chevex: I think that, if there are actual problems in switching the App Pool to .NET 4.0, then Microsoft would love to hear about them. It pretty much should "just work". They did a lot of work to get the CLR 2.0 and 4.0 to work together. – John Saunders Feb 18 '11 at 21:00
  • John, this question isn't about converting the 3.5 app to 4.0. It's about getting the 4.0 app I have created to work within the 3.5 app. If you would like, I can send you details elsewhere about what happens if you simply switch the app pool to .net 4. – CatDadCode Feb 18 '11 at 21:02
  • @Chevex: it would be better if you were to post a question on SO about why you can't just change the AppPool. That way, you might get solutions. – John Saunders Feb 18 '11 at 21:10
  • No, because the issues with getting the company app to compile after targeting .net 4 has absolutely nothing to do with getting a .net 4 app to run under a .net 3.5 parent app. – CatDadCode Feb 18 '11 at 21:11
  • @Chevex, try suggestion below, it almost always fixes this kind of problem – Hawxby Feb 18 '11 at 21:14
  • @Chevex: This is why I'm not suggesting a recompile. I'm suggesting changing the AppPools of the entire app to .NET 4.0, which shouldn't leave you with more than an issue of cleaning up web.config files. Those errors should show up ass soon as a page controlled by that web.config is answered. Easy to find them, and not too tough to fix them. No changes to the applications themselves. – John Saunders Feb 18 '11 at 21:23
  • @John, switching the parent app to .net 4 causes the app to fail with numerous errors. In fact, just loading the default page of the parent app while the app pool is targeting .net 4 gives the exact same error I included in my screen shot. It cannot be switched. I don't know what is so hard to understand about that. – CatDadCode Feb 18 '11 at 21:27
  • @Chevex: I simply don't believe you. I've used ASP.NET since 1.0 and have not seen any problems with switching the ASP.NET version that 1) weren't trivial to find and 2) weren't fixable by simple edits to the web.config files (like changing the version number on an assembly name). The only exception was .NET 1.1 to 2.0, which decided to "fix bugs" in .NET 1.1. – John Saunders Feb 18 '11 at 21:29
  • Bottom line: This question is not about what you are so keen on arguing about. If you would like to create a question of your own, asking what you want to ask, and then answering with the answer you would like. You are free to do so. – CatDadCode Feb 18 '11 at 21:58
  • @Chevex: I was actually offering the change in AppPool as a solution, fiven that I don't know of any significant reasons not to do it. – John Saunders Feb 18 '11 at 23:23
  • Which. Breaks. The. Parent. App. The app pool for the nested app is already targeting .net 4. The app pool for the parent app CANNOT BE CHANGED. Changing the app pool to .net 4 causes compiler errors in the parent app. The parent app can't run if it wont compile. I can't say it any clearer. – CatDadCode Feb 19 '11 at 00:42
  • @Chevex: from what I read in the linked article, the fixes are trivial and could largely be automated. Maybe I missed something, but it looked easier to fix the .NET 3.5 applications to run under 4.0 than the other way around. Did I overlook the code changes? Because I didn't see any in http://www.asp.net/learn/whitepapers/aspnet4/breaking-changes#0.1__Toc245724860. – John Saunders Feb 19 '11 at 01:41
  • You are not a developer on this project. You do not manage the horde of assemblies, classic asp code and the horrid authentix authentication system built off a 16 bit DLL. My telling you that it isn't possible and that this question is not about cconverting this mangled app to 4.0, should have been enough. I am considering the matter closed. Any further comments will be ignored. – CatDadCode Feb 19 '11 at 06:30

6 Answers6

12

Web.config inheritance is unfortunately not something you can turn off completely; Specifically, the top section in the web.config that defines which config sections exist in the web.config cannot be ignored/overridden inside a child application.

The solution is documented here(asp.net 4 breaking changes documentation); Essentially you have to move the values that are currently in the top application up into a machine/FrameworkVersion specific config file and then wrap all(or at least, most) of your root web.config in a location tag with inheritence disabled.

Chris Shaffer
  • 32,199
  • 5
  • 49
  • 61
  • 2
    The page linked has been a great help. Thank you. I will let you all know how it went later this evening. – CatDadCode Feb 18 '11 at 21:19
  • 1
    This did it. Thank you for actually answering the question I asked. – CatDadCode Feb 18 '11 at 21:37
  • 1
    Good question, and answer. I've never been a fan of the design of the .NET config files, but this solution proves once and for all that the design is bad from the ground up. Modifying a machine wide config file, so that I can get a single parent-child pair of web applications working is terrible! – Greg Woods Nov 07 '14 at 10:09
1

In my applications I more or less succeed with nested applications by using the <location> element together with <clear /> and similar elements in the web.config.

This is an excerpt from a web.config file of mine:

...
<!-- Do not inherit. -->
<location path="." inheritInChildApplications="false">
    <system.web>
        ...

The idea is to put all sections that you do not want to inherit to child applications within those location elements, as in my example above.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
1

Have you tried setting the "inheritInChildApplications" attribute to "false" in the parent folder's web.config file?

See Saul Dolgin's answer to a similar question for how to do this.

Community
  • 1
  • 1
Kevin Pang
  • 41,172
  • 38
  • 121
  • 173
0

Edit: As mentioned first port of call is to make sure each application has it's own application pool. Double and triple check this as a .net 3.5 site and a .net 4 site in the same app pool will cause the entire app pool to break.

Next, try remove the entire scripting section group, from my experience it solves it and i've not noticed any problems

Hawxby
  • 2,746
  • 21
  • 29
  • Sounds like his problem is it's referencing the incorrect web.config. Making changes like this would break his parent application. – mellamokb Feb 18 '11 at 20:53
  • That would normally generate a "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level" error. – Hawxby Feb 18 '11 at 20:55
0

Assuming that your current site uses AppPool1 targeted to .NET 2.0

Create AppPool2, target it to .NET 4.0 and use it by virtual dir of your app.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
0

Make sure that stuff isn't in the machine config for the app pool. If so, just delete it from your web config.

Adam Jaskiewicz
  • 10,934
  • 3
  • 34
  • 37