Two different version of .net on server - asp.net

Is it possible to have two different versions of the .net framework on the web server then have one Virtual directory use the 2.0 version and another virtual directory use the 4.0 version in the ASP.Net tab in IIS?
A customer has all of it's ASP.Net apps compiled in the 2.0 frame work. But they want to install a newer ASP.Net app in a different virtual directory. And this new app was created in the 4.0 frame work.
How can they configure this on IIS?

Yes it is possible to have multiple versions of .NET installed on a web server.
You can run multiple applications in IIS on different frameworks.
However an application can only use ONE framework. As a virtual directory is part of the application it runs under the application's framework. E.g. Application (.NET 2.0), it's Virtual Directories are CHILDREN of it, so they are running under .NET 2.0.
Further details on IIS, Applications and Virtual Directories
The solution would be to run 2 applications, one for 2.0 and one for 4.0.
Luckily, in IIS, there is a method to convert a Virtual Directory into a Virtual Application, which gives you the opportunity to use a different Application Pool, and therefore different framework version.
I'm going to recommend you read this StackOverflow post, that is far more eloquent then mine.
StackOverFlow - difference between application and virtual directory

Related

Asp.net website not starting default.aspx (apache 2.4 on Windows 10 Pro; IIS 10)

So, I setup a Win10 box as an Apache server; built VS19 Asp.net webforms app, which works as expected when run in VS. published to the C:\Apache24\htdocs folder. Now, I setup port forwarding on my ISP-provided "Internet IP Address" to point to my local server. If I use any browser (outside of my LAN) to access that address (e.g. http://xx.yy.zz.qq - not showing actual IP for security reasons) I will see the page titled "index of /", and the list of files that I published to that htdocs folder. If I put in INDEX.HTML file in that folder, it will be displayed; but since I see Default.aspx as the 1st entry in the IIS Default Documents list, with NO index.html present, I still just see the list of files, not the aspx. I don't think the fact that I've not yet established a DomainName-to-IP binding should make any difference to this issue, but I can't be sure. Any thoughts? As you might guess, I've not done this before! :) ). TIA!
Jim
I made sure that the VS instance of the website was not running, just in case that might cause IIS confusion; but I don't think that would be the case.
As noted, I can't see how a non .net server going to run/launch/process correctly aspx pages that require IIS as the web server?
I mean, IIS can't run a web site designed for Apache, nor can say IBM "web spere" web server either.
I am trying "hard" to think how a application built in .net framework going to work with a web server that not designed to work with the .net framework?
I mean, if you have a computer, and have a word document, then you need word installed to work with that document.
If you have a PDF file on your computer, then you have to install some PDF software to use that PDF document.
A web server is not some "magic" box, but is a plane jane computer, with some software installed on it. So, if you build a aspx .net framework site in .net, then that computer will require the .net framework to have been installed, and require the correct type of software to work with those pages - in this case IIS.
Now, to be fair, you CAN do this with .net core, since .net core can run on quite much "any" computer (that supports nigex). However EVEN in that case, they FAKE and TRICK you, since how they achieve this "magic trick" is when you build the .net core application, the build process includes a WHOLE WEB SERVER as part of the build!!! (this lighter weight web server (kestrel) thus can work if you forward the ports and requests say from Apache, or quite much any web server. But MAKE NO MISTAKE here, a WHOLE .net core compatiable web server is included in that build, and thus that .net web server IS STILL required to run that .net code.
Unfortunately, the .net framework (as opposed to the .net core choice) does not upon build of your web site INCLUDE that WHOLE WEB SERVER as part of the build.
So, .net framework sites requite the correct software to work, and that correct software in this case is the web server called IIS (Internet Information Services).
You can no more suggest/attempt/assume that some program to load and read a PDF document is now out of the blue going to consume and work with Excel files, or word files.
hint:
Software build to a particular library of code requires the correct software to run and work. Kind of simple!!
So, a computer with a web server?
That is JUST a computer with software installed on it, and you need the correct software installed on that computer to consume the files etc. it was designed form.
Apache web server can no more consume a "application" or "web site" designed for IIS then it can consume other files etc. that are designed for use with a 100% different application. this is how all software works, and it not clear why you would think that Apache, or IIS, or word or Excel would work any different at all here?
Now, there was the "mono" project, and that was a port of .net framework that allowed the .net framework to run say on Linux, and there are some examples of some attempts to run aspx pages that way, but it is a galactic mess of epic proportions, and really not the way to go.
However, as stated, the .net core system DOES run on just about any platform, and it does have the above "magic trick" of being able to run on Apache, but behind the scenes, that software build actually includes a WHOLE WORKING web server that is .net core compatible, and that WHOLE web server is included with your build, and thus some are "fooled" by this magic trick that .net core web sites can run on Apache. They look like they can, but they are not, and in that example case (of .net core, NOT .net framework), the site seeming to work on the Apache web server? Nope, what occurs is the Apache web server simple hands off any web request to the REAL WORKING AND INSTALLED .net core web server!!! (thus Apache really only acts as a router, or "hand off" machine, and all the REAL web processing occurs in the .net core web server called kestrel).
So, you can do as you ask, but you would have to dump "web forms" and build the web site with aspx pages as a .net core web site. If you do that, then YES you can use Apache, and it will work, but behind the scenes, it ONLY works because that build process of the .net site ALSO includes THAT WHOLE COPY AND WORKING COPY of a .net core web server as part of the build. As noted, this magic trick option during the build process is NOT available for .net framework, but is most certainly available for the .net core choice.
So, in your case of using Apache? Software designed for a particular type of web server must use the correct type of web server. Same goes for IIS - it can't consume nor run a web site designed for Apache. I mean, how software works on your desktop is not any different then how software on a web server
The pages you have implemented with the .aspx are part of the ASP.NET Web Forms framework. This framework is part of the .NET Framework. The main server required to host Web Forms applications is IIS (Internet Information Services). Since you are working on a Windows machine, you can research how to setup IIS to host your Web Forms site if you wish. If you still want to use Apache as the front end for your site, you can even have it proxy requests to your site hosted in IIS, although there's probably little benefit and much complexity from such a setup.
Apache out of the box does not include support for hosting Web Forms applications. There is an open source project called Mono that seeks to implement an alternative version of .NET Framework and allows the use of alternative web servers such as Apache. But Mono has largely been superseded by .NET Core.
.NET Core is the official replacement for .NET Framework. It is open source and cross platform by default, and the ASP.NET Core web framework that runs on .NET Core includes a Kestrel web server. This can be utilized with Apache (or any other web server) in front of it, acting as a reverse proxy. It is not a magic trick, but a rather standard approach for web applications these days. However, ASP.NET Core does not include the Web Forms framework, so you would need to re-implement your application in a more modern alternative that's supported by ASP.NET Core if you intend to stay in the .NET ecosystem. There are many alternatives in ASP.NET Core including MVC, Blazor, Razor Pages, and Web API.

Publish .NETCore 2 API and host on IIS

I've created a .net Core 2 API and published it to the server.
The file structure looks very odd compared to a normal .Net MVC structure
Normal Structure I am familiar with
And this is the structure of the deployed .NET CORE 2 API
Now if I just try and convert that folder to an application like a normal ASP.NET app, it doesn't work.
I've installed the .NET Core Windows Server Hosting bundle on the server, but I'm still missing something.
Where do you add this code to enable IISIntegration ?
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
That code goes in Program.cs, but it's the default, so you should already be fine there.
The ASP.NET Core file structure is different than MVC 5, but it all pretty much works the same, once you've installed the .NET Core Hosting Runtime. You drop the published files in a directory on the web server. Then, you set up a site in IIS to use that directory. The only thing slightly different is that you need to edit the App Pool and set it to "No Managed Code", instead of a particular .NET runtime. Other than that, it should all just work.
That said, if your screenshot is a complete listing of the files, then you do seem to be missing some stuff. It's possible the publishing process failed at some point. Try to republish.
Background
The way ASP.NET Core works is fundamentally different than previous ASP.NET web applications. Whereas you used to have all the HTTP modules and such coming from the monolithic .NET Runtime installed on the machine, ASP.NET Core apps are completely self-contained. A Core app is in fact merely a console application. In an IIS setup, the actual web server is Kestrel, which either bundled into the Core app or available from the .NET Core runtime. IIS works as a reverse proxy. Handing off requests to Kestrel and then returning the responses it gets from Kestrel (hence the "No Managed Code"). With IIS deployment your app is a DLL, but it can also be entirely self-contained and deployed as an executable. The point is that, yes, the file structure and such is very different because it fundamentally works in a different way.

How to route request from one application pool to another in iis 6.0

I have got two web applications (separate virtual directories) residing in the DefaultAppPool on Windows Server 2003. My first application has got a link and when I click on it, the second application opens up.
Now I want to use different .Net framework for both web applications and for that in IIS 6.0, I will have to host them in separate app pools.
Now the question is - is it possible to host them in different app pools and keep the behavior intact so that if I click on the link in first web application, it can still open the second web application hosted in a different app pool?
Thanks in advance,
D
I think I've found the solution and it is simpler than what I actually thought.
Steps I took:
Create another app pool in IIS 6.0 on Windows Server 2003
Assign one of the web applications to this pool. So now I have two web applications in two different app pools. Currently both are having ASP.NET version as 2.0.50727
Change the ASP.NET version of one of the applications to 4.0.30319. So interesting fact to understand here is - in IIS 6, you can't set the .NET framework for an app pool. It actually assumes it from the first application in it and then applies it to all the web applications residing in this app pool
And it is done!!
It can be checked to list all the sites and which .NET versions they are configured to by using aspnet_iisreg -lk. Run this command from your .NET framework directory. For ex: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
Both the sites with different .NET framework will be listed
Hope this helps.

How to host an ASP.NET Web Applications site on IIS 7

I'm locally working on an ASP.NET Web Applications site. It's almost finished so i wanted to try and put it in an IIS server.
The IIS server is running on a different server. What do i need to do to run my ASP.NET web site in that remote IIS server?
I tried to following:
I copied my entire project directory (so including the .csproj file, the bin folder etc.) to the following location on the remote server, where IIS is running C:\MyProject.
In IIS manager i added a Virtual Directory under Default Web Site. Located my Web Site files in C:\MyProject and added that folder. Then in IIS manager i converted that Virtual Directory to an Application.
But when i browse to my Web Site i get an error:
HTTP Error 500.23 - Internal Server Error
An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.
So this is probably not the way to do it. I don't think i can just do a Deploy, because i never set up any .axd(?) or anything.
So my question is, what do i have to do in order to run my Web Site on IIS..?
The error will be probably because of, you developed the site in .net version 2.0 and try to run under the Integrated pipeline apppool that runs under .net framework 4.0.
SoL:
Create a new apppool with classic mode and .net framework equals to your application developed framework.
attach the newly created apppool to your virtual directory.
Note: For deployment, you don need to copy .csproj or unwanted solution files to destination location.
If it is otherway around, (i.e,) application is .net 4.0 and apppool is 2.0 please follow the below steps.
Update .net framework in the server to 4.0 if you have only 2.0.
Then register .net 4.0 version in IIS by running the following command in command prompt.
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -i
Try changing Application pool to Classic. To do that open Advanced settings of your application in IIS manager and change Application Pool. There should be "ASP.NET v4.0 Classic" or something similar according to your framework version.
http://technet.microsoft.com/en-us/library/cc731755(v=ws.10).aspx

Install ASP.NET 4.0 alongside ASP.NET 2.0 on IIS6

I've read where you create a new application pool, one for 2.0 sites and one for 4.0 sites. But there is no option I see when creating a pool to configure the framework.
My problem is I have several 2.0 sites running as the Default Web Site. I added a WCF 4.0 service under a new virtual directory and set the framework to 4.0. I also put it in a separate app pool.
Now, I can only get one working at a time. Either the 2.0 sites or the 4.0 site. I get:
It is not possible to run two
different versions of ASP.NET in the
same IIS process. Please use the IIS
Administration Tool to reconfigure
your server to run the application in
a separate process.
Is it possible to do this under IIS6 and Windows Server 2003?
To clarify: Each app pool binds to the .NET framework of the first web site that uses it, in order of application startup. That first site will run fine, but all other sites will be restricted to the same app pool. You need at least one app pool per framework version; and in my experience, the most robust setup is one app pool per application - this way, you can switch framework versions without worrying about other applications, and you can kill individual applications through task manager when the need arises.
The App Pools don't need configuring, just make sure the 2.0 sites are running as one, and the 4.0 site running as another.

Resources