Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a .NET 4.0 web application within a .NET 3.5 web application?

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

like image 781
Chev Avatar asked Feb 18 '11 20:02

Chev


People also ask

Are .NET versions backwards compatible?

The . NET Framework 4.5 and later versions are backward-compatible with apps that were built with earlier versions of the . NET Framework. In other words, apps and components built with previous versions will work without modification on the .

Can multiple versions of .NET be installed?

Microsoft designed the . NET Framework so that multiple versions of the framework can be installed and used at the same time. This means that there will be no conflict if multiple applications install different versions of the . NET framework on a single computer.

Can .NET Core and .NET framework coexist?

NET Core is portable, and can be tuned to run across different supported platforms. Depending on how you target your projects, it's possible to have . NET Core code run on the . NET Framework, Mono and Xamarin platforms, on Windows 8 and Windows Phone, and on the Universal Windows Platform (UWP).


3 Answers

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.

like image 178
Chris Shaffer Avatar answered Sep 19 '22 04:09

Chris Shaffer


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.

like image 43
Kevin Pang Avatar answered Sep 23 '22 04:09

Kevin Pang


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.

like image 28
Uwe Keim Avatar answered Sep 21 '22 04:09

Uwe Keim