IIS configuration in WiX - iis

Is it possible to configure IIS using WiX?
If it is then how do I find out which ASP.NET and IIS features (for example, add MIME types, add application string, add connection string, etc.) can be configured in WiX?

Related

Kentico - Global.asax file issue after publishing

I have installed a new Kentico web application and I can browse the site without any problem. This site is hosted in IIS, Now I want to add some customization and created another web application application using MVC and registering routes etc in application start of global.asax event.
Kentico project also has a global.asax file and it contains some code logic.
When I publish my custom web project, It overwrites the existing default Kentico global.asax with global file from my application and application breaks.
Is there any way to have a 2 different global.asax file in a web application with different names? I want both global files should execute separately.
No, I don't believe you can do that. What you can do is publish your MVC site to an application in IIS instead. You might find the following article from Kentico helpful: Creating virtual directories and application pools in IIS 7.5 and 7.0

Inherited web.configs with ASP.NET Core Equivalent

My company is exploring ASP.NET Core. We currently use ASP.NET Web API 2 & MVC 5.2.2. We deploy our applications under IIS using the following configuration:
VirtualDirectory1 (web.config with connection string and other non-specific information)
App1 (app specific web.config)
App2 (app specific web.config)
Api1 (api specific web.config)
Api2 (api specific web.config)
VirtualDirectory2 (web.config with connection string and other non-specific information)
App1 (app specific web.config)
App2 (app specific web.config)
Api1 (api specific web.config)
Api2 (api specific web.config)
As you know, each application or API inherits configuration from the parent web.config under IIS, so each inherits the parent connection string. We use a single copy of each application on the server. Can we deploy ASP.NET Core applications the same way?
I found StackOverflow articles on nested objects and environment specific AppSettings.json configurations but this does not appear to be the answer.
UPDATE 1:
The above is a multi-tenant configuration where each virtual directory is a tenant. The web.config at the root of each virtual directory contains the connection string all apps under the virtual directory use. 
I read that a web.config file must exist for ASP.NET Core apps to work under IIS.
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/index?tabs=aspnetcore2x#webconfig-file
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?tabs=basicconfiguration#webconfig-file
So I wonder if that the connection string is visible to the ASP.NET Core applications.
Update 2:
A.F.A.I.K, web.config can be loaded from the app content root, but the one we need resides up in a virtual directory. A AspNetCoreModule maintainer told me environment variable inheritance (which applies in this scenario) is unreliable, and no plumbing exists to access other inherited configuration. The web.config only exists to configure IIS for ASP.NET Core applications.
The best solution seems to be using host headers the way Saaskit does.
https://github.com/saaskit/saaskit
This requires us to change our IIS deployment and add a DNS record per tenant, but it is the next best thing to inherited web.config files. I would like the ASP.NET Core team to consider introducing a ASP.NET Core-approach to inherited settings that gives us the same ability inherited web.configs did.
Putting tenant specific settings in a file up in a virtual directory is out of the box thinking, but it greatly simplifies multi-tenant support. Our MVC & Web API code needs nothing extra. It simply retrieves settings through the ConfigurationManager as though no other tenant exists.
We have one website under IIS and one virtual directory per tenant. Each tenant is accessed via its URI.
https://myfqdn.com/tenant1/myapp
https://myfqdn.com/tenant2/myapp
tenant1 and tenant2 are virtual directories containing a tenant specific web.config, so invoking https://myfqdn.com/tenant1/myapp loads tenant1's web.config and myapp inherits its settings for requests. /tenant2/myapp loads a different web.config.
Myapp is unaware of which virtual directory it was invoked from on each request. We install myapp in one physical location but add it as an application under each tenant's virtual directory. The result is we have one copy of the app, multiple instances, and no multi-tenancy plumbing.
ASP.NET Core is not bound to IIS so the same approach won't work as for ASP.NET. But you can implement a similar approach if you would like by moving your common settings to some SharedSettings.json and use this.
.ConfigureAppConfiguration((hostingContext, config) =>
{
var env = hostingContext.HostingEnvironment;
var sharedFolder = Path.Combine(env.ContentRootPath, "..", "Shared");
config
.AddJsonFile(Path.Combine(sharedFolder, "SharedSettings.json"), optional: true) // When running using dotnet run
.AddJsonFile("SharedSettings.json", optional: true) // When app is published
.AddJsonFile("appsettings.json", optional: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
config.AddEnvironmentVariables();
})
Read more here: Sharing appsettings.json configuration files between projects in ASP.NET Core

difference between Microsoft.Owin.Host.SystemWeb and Microsoft.AspNet.WebApi.WebHost nuget packages

I want to host my WebApi project in IIS and Self-Host context. In my researches, For IIS hosting, I found these two packages:
1- Microsoft.AspNet.WebApi.WebHost (src)
This package contains everything you need to host ASP.NET Web API on
IIS
2- Microsoft.Owin.Host.SystemWeb (src)
OWIN server that enables OWIN-based applications to run on IIS using
the ASP.NET request pipeline.
My WebApi app can be loaded in IIS with both of them. So the question is what is the difference between these two packages and in which condition I should use them.
P.S.
I get some error when hosting with second package in some scenarios.
This package Microsoft.Owin.Host.SystemWeb is required if you want to host Web.API on a OWIN pipeline and you are hosting this pipeline on IIS (you don't need this for self-hosting, for example inside a console app).
The other one is required for "classic" Web.API hosting and has nothing to do with OWIN itself.
I guess you want to run OWIN (because you're self hosting too), so you need the second one.
BTW, the OWIN equivalent of Microsoft.AspNet.WebApi.WebHost is Microsoft.AspNet.WebApi.Owin.

Multiple ASP.NET Web API on the same IIS

I need to create 3 separate and independent versions of my ASP.NET WEB API and host them all at the same port and in the same IIS.
So, let's assume that my current API runs at:
http://xxx.xxx.xxx.xxx/api
I need to replicate it to
xxx.xxx.xxx.xxx/test/api
xxx.xxx.xxx.xxx/dev/api
but it is very important that each one will have it's own configuration on IIS.
The reason for that is that I want each "version" of the API to have a different connection string.
Of course this will have to be done with out any change in my current code, just via IIS setup.
You can create applications under an IIS site to accomplish this. You can even use WebDeploy to deploy them all. Follow this blog post -
http://dotnetcatch.com/2016/03/03/simple-service-versioning-with-webdeploy/

How to setup "enabled protocol" for IIS application using intallshield installation

I'm trying to create an MSI for a .NET WCF web service in IIS 7.5. The service is going to use TCP instead of HTTP for a protocol.
In order to use TCP, I have to add the text ",net.tcp" to the "Enabled Protocols" setting of the application's virtual directory (Under "Advanced Settings..." in the IIS managment console).
Is there any way to configure the "Enabled Protocols" for a virtual directory in IIS 2012? At the moment, I don't see a way to configure this setting
I've frequently observed that with each new release of IIS there will be a setting or two that InstallShield is lacking. After a release or two they typically catch up. In the meantime I use InstallShield to do most of the IIS configuration and then use the IIS provided "appcmd.exe" utility in a custom action to patch the rest.

Resources