IIS Website with multiple web applications underneath and different ports? - iis

I am relatively new at configuring IIS and am wondering if the following scenario is possible.
My application consists of 2 Web apps. 1 is an ASP.NET Core App that hosts a Javascript SPA. I have a second MVC App that is a combined Authorization Server using OpenIddict and the main API that the SPA talks to.
On my dev machine these 2 apps run on different ports.
These 2 apps go together to make our solution for any given customer. I can get this all working on IIS treating each app as it's own website with it's own port.
But I would like to be able to bundle these 2 apps under 1 website. Ultimately we will have several customer websites and each "website" really consists of these 2 apps bundled together.
I understand that I can create a single website and then convert my 2 existing sites to a web application. So 2 web apps sit under the main web site. But these all will run under the same port.
I would really like my API and Authserver to run on a different port. Is there a way to each this type of scenario?
What is the recommended best practice for what I am describing?
I do not want the API / Auth Server project to be shared by all the customer sites. I want each customer site to have it's own instance of the Authorization server and API.
It would be great if you could create 2 websites and then sort of group them into a parent website container (if that makes any sense).

You can create two applications within your website on IIS. Then each application would be accessed as http://customerwebsite/app1 and http://customerwebsite/app2

Related

Consul and IIS hosted applications

I'm trying to to use Consul to implement service discovery in a microservice architecture.
I've tried to setup my dotnet core 3.1 application to self register with Consul, and I have 3 VM's running Consul, automatically picking a leader of the 3.
Reading numerous examples online, they all have one thing in common: I need to know the URL of my microservice. Now, using IIS I have 2 options when it comes to hosting; Sites and applications. Sites have a certain URL connected to them (Example: http://api.microservice1.com) whereas application use the servername in the URL (Example: http://webappserver1/microservice1).
As I have 2 servers (Let's say webapp01 and webapp02) I can't know what server the service is running on, and therefore I can't seem to find a solution as to using IIS applications instead of IIS sites. My service would be one of the following routes:
http://webapp01/microservice1
http://webapp02/microservice1
Is there a way for me to use IIS applications and not sites? How would I register my microservice with Consul? Perhaps I'm just forced to use IIS sites and not applications?

How combine 2 web apps under one domain

I have 2 ASP.NET core projects, first one lets call it Test which contains angular SPA, and the second one Test.API which exposes a RESTfull API to the angular app, now i'm deploying 2 apps to Azure web apps under custom domain.
Test is: www.mydomain.com
Test.API is api.mydomain.com
My problems is that any call from my angular app causing an additional OPTIONS request (delay) that i want to eliminate, by rewriting request (Not redirect) that points to api.mydomain.com/* to www.mydomain.com/api/*.
And also keeping 2 different web apps.
Tried to use asp.net - IIS URL Rewrite module but without any luck, can someone provide me with working example or suggest other way to accomplish this.
Please try to use Azure Web App Virtual Directory. Refer to this article to know how to deploy multiple virtual directories to a single Azure Website. Please try to deploy Test web app to the root project, and deploy Test.API to the virtual directory. After this, we can use www.mydomain.com to access the root web app, use www.mydomain.com/api to access the web app existed in virtual directory.

Self Hosting Web Application versus IIS Hosting?

I am in the process of building a Web based client for a Server application which is running as a Windows Service. The server application currently has a Windows Form based Client Application written in C# and the idea is to obsolete it and provide a new Web based Client Application. The Server application will be exposing REST based APIs and the Client Application would be using the REST APIs to communicate with the Server Application. (Currently the Server App exposes SOAP based endpoints which are consumed by the Windows Form Based App)
The Browser based client application would be written using Angular JS. The Client Application would be used by at max 10 concurrent users. The App is targeted for system administrators and would be used inside the enterprise environment.
Another requirement is to integrate Active Directory Authentication for the Client Application. So given the performance requirement and authentication requirements, I am wondering whether I should use IIS for hosting the Web Application. Or should I just use the existing Server to self host the web pages.
If at all I go with Self Hosting option, would Katana Self host be a good option? Or should i use WCF Rest kit to serve the pages?
What are the performance implications of using a Self Hosted mechanism for hosing the Web Application compared to IIS?
Any suggestion would be greatly appreciated.
WCF REST Starter kit is still in second preview 2 version from 2009 so I'd be pushed to recommend using it.
The question of IIS or self host depends, do you need the features that IIS has out of the box like logging, restart after failure, etc?
My suggestion would be to use ASP.NET Web API (or Nancy, which is an excellent choice too) but keep your hosting layer separate from your application layer so you have the flexibility to decide how you host your service later on.
The second suggestion is performance test early on, pick a hosting mechanism and measure how the service copes under load - you may find out that you're worrying about something that you don't need to.

How to deploy a WebAPI application and an ASP.NET application in one web site on Azure?

I have two projects: an ASP.NET web application and a WebAPI application.
Web application uses the WebAPI application via AJAX.
To avoid cross domain problem, I want to the two projects deployed under one domain on Azure.
For example:
http://www.mycompany.com/api/products is a web api.
http://www.mycompany.com/index.html is the home page of the site, which calls the web api via AJAX.
Is it possible?
Yes, you can host multiple applications on the one site.
Go to Configuration / Virtual Applications and Directories:
Simply host your app under
/ site\wwwroot
And host your API under
/api site\wwwroot\api
And make sure your API is copied to the api sub-directory.
Make sure you tick the Application box.

Recommended approach to hosting a two-tier web application in Azure Web Sites

I'm fooling around with a WebAPI application I've developed in two solutions: one solution is the WebAPI / serverside solution with db access using SQL server, the other is a durandalJS client application. I have the WebAPI bits hosted in an Azure Website right now, but I'm not sure where to put the client solution.
Should I throw it in its own website and just have it make requests within azure across to the other website? I want to avoid putting them in the same solution because I would eventually like to practice load balancing the front-ends when I have more dough to play with.
Idea of cloud like Azure is pay as you go. If you do not have the volume currently to load-balance, why create two websites and pay for them both regardless of the usage? You can have just one web site and host both the web application and web API. In the future, if you want to separate out API piece and load balance web app, you can do that when you have the volume. For this approach to work, structure the solution like this. The Web API piece will be just an assembly which you can reference in the Web application itself and host it in the same web site as the web application. In future, if you want to separate out, create a new empty ASP.NET Web application and host the Web API referencing your Web API core assembly.

Resources