Aspnetcore.docs: Cannot I Run AspNetCore app as windows Service and as Web App using IIS(Default Reverse Proxy)

Created on 8 Feb 2019  ยท  10Comments  ยท  Source: dotnet/AspNetCore.Docs

As of now in order to access the web app, i am creating a reverse proxy from URL Rewrite, apart from that, i tried added --console to arguments in web.config(making <IsTransformWebConfigDisabled>false</IsTransformWebConfigDisabled>).

the app loads but intermittently stops that it can only run as a service.
Doubt : Doesn't IIS use arguments specified within web.config all the time.

Or do we have any solution for creating IIS reverse proxy to web app directly without manually creating it everytime.


Document Details

โš  Do not edit this section. It is required for docs.microsoft.com โžŸ GitHub issue linking.

Source - Docs.ms

Most helpful comment

@guardrex Looks crazy but i was able to do it without transformation.
Just added a web config and just replaced default %LAUNCHER_ARGS% with --console.
which worked for case.

But if there are any environment specific arguments needs to be passed we need transformation.

And i feel to have web config transformation task in release too. currently we are doing on appsettings.json. like wise we can have that task within Release pipeline in devops.

All 10 comments

Sorry, Its just a small misconfiguration from my side, closing this issue.

Yeah ... I was about to say it should work. IIS should honor the arg you're passing, thus it should fire up the app with the switch that will make this service app run as a normal web app.

Part of the reason we didn't address this scenario (IIS) is that it's more likely that devs will test _as a service_ in a staging environment ... not as a web app. Running as a web app was something we wanted purely for development locally.

Anyway ... glad it was just a little misconfiguration. _On a Friday_, that's a good result. ๐Ÿ˜€ :+1:

Yeah ... I was about to say _it should work_. IIS should honor the arg you're passing, thus it should fire up the app with the switch that will make this service app run as a normal web app.

Part of the reason we didn't address this scenario (IIS) is that it's more likely that devs will test _as a service_ in a staging environment ... not as a web app. Running as a web app was something we wanted purely for development locally.

Anyway ... glad it was just a little misconfiguration. _On a Friday_, that's a good result. ๐Ÿ˜€ ๐Ÿ‘

in .Net Core web app as we don't see web.config by default, Do we have any option to add arguments to web config while publishing. it could save lot of time for me.

Currently i want to use .net core app as web app and windows service to serve it as a web hook.
MVC Web API endpoint just receives requests and queues them in msmq, and a the windows service job will take care of processing them in scheduled mean time.

option to add arguments to web config while publishing

I did just did the write up of Vijay's _web.config transform_ content for the docs. Take a look at .......

https://github.com/aspnet/Docs/pull/10841/files#diff-6267489d2d2be3ec3606466d9e88d381

It's not published yet, so you can only read it there. It should be published to the live docs soon. The web.config transformation bits work in 2.2+, so you could use that right now to perform a web.config transform on publish depending on (for example) the profile or the environment.

Just one thing tho ..... I show (and he shows on the repo that he set up) the simplest case ..... setting an env var. What you'd be doing is transforming the <aspNetCore> element, and the topic isn't going to show that. It should be fairly easy to work out tho. If you run into trouble making it work, open an issue on the aspnet/AspNetCore issues at https://github.com/aspnet/AspNetCore/issues and ping @vijayrkn on the issue. Hopefully, it will be easy and you won't need to open an issue tho ... Vijay is ๐Ÿƒ๐Ÿ˜… most of the time, so it's best not to ping him unless absolutely necessary.

@guardrex Thank you very much I will look into it.
So it requires .Net Core 2.2 above. so the same needs to be installed on servers.

Even i will try from my side. Once again thanks for your help.

@cvbc2010 The transforms run when the app is published locally, so you should be able to make them work if 2.2 is installed locally.

You could ... in theory .... be using 2.2 locally to produce a 2.1 app _and the transformation should work_ and then deploy the 2.1 app to a server that only has 2.1. That's fine :+1: if that's your setup. It won't matter server-side for that scenario because the web.config will have already been produced locally by the SDK and deployed with the application.

To confirm if the SDK is working locally and giving you a web.config with the proper transformation, open the publish folder and visually inspect the web.config file to confirm that the transformation worked correctly.

@cvbc2010 The transforms run when the app is published locally, so you should be able to make them work if 2.2 is installed locally.

You could ... in theory .... be using 2.2 locally to produce a 2.1 app _and the transformation should work_ and then deploy the 2.1 app to a server that only has 2.1. That's fine ๐Ÿ‘ if that's your setup. It won't matter server-side for that scenario because the _web.config_ will have already been produced locally by the SDK and deployed with the application.

To confirm if the SDK is working locally and giving you a _web.config_ with the proper transformation, open the _publish_ folder and visually inspect the _web.config_ file to confirm that the transformation worked correctly.

I am using Azure DevOps for Build and Release pipeline. so Build machine should atleast have this .net core 2.2 right.

Sounds good. If you run into trouble, ping Vijay on an aspnet/AspNetCore issue. Ping me on the issue if you open it (@guardrex) so I can follow the discussion. We'll modify the docs as needed depending on the conversation.

One thing that bothers me right now is that our example cases assume the _simplest case_ setting some environment variables. If things get more complicated when dealing with the <aspNetCore> element, we might need to do some more work on the topic and provide some added guidance.

@guardrex Looks crazy but i was able to do it without transformation.
Just added a web config and just replaced default %LAUNCHER_ARGS% with --console.
which worked for case.

But if there are any environment specific arguments needs to be passed we need transformation.

And i feel to have web config transformation task in release too. currently we are doing on appsettings.json. like wise we can have that task within Release pipeline in devops.

Was this page helpful?
0 / 5 - 0 ratings