# Elastic APM with ASP.Net and IIS server configuration

**URL:** <https://discuss.elastic.co/t/elastic-apm-with-asp-net-and-iis-server-configuration/305135>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [May 19, 2022, 6:42am UTC](https://discuss.elastic.co/t/elastic-apm-with-asp-net-and-iis-server-configuration/305135 "2022-05-19T06:42:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Namita\_Jaokar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/namita_jaokar/32/104106_2.png) [@Namita\_Jaokar](https://discuss.elastic.co/u/Namita_Jaokar)\
**Post date:** [May 19, 2022, 6:42am UTC](https://discuss.elastic.co/t/elastic-apm-with-asp-net-and-iis-server-configuration/305135/1 "2022-05-19T06:42:50Z")

</div>

Hi,

I want to instrument [asp.net](http://asp.net) MVC application with Elastic APM agent and got through this link **[Configuration on ASP.NET | APM .NET Agent Reference [1.12] | Elastic](https://www.elastic.co/guide/en/apm/agent/dotnet/current/configuration-on-asp-net.html)** which requires to add the configuration in the web.config file of the application.  
Is there a way to configure the application without making changes in the application, Like the way we have it in the aspnet core applications with zero code changes method of configuration.

Secondly, I want to configure my _ **aspnetcore** _ application by deploying it in IIS server. Until now I have tried configuring the elastic apm agent with standalone executables using **zero code changes method of configuration**

Is the agent configurable with the IIS server as well? Do i need to have additional configurations in case of applications on IIS -(_**aspnetcore and [asp.net](http://asp.net) any of them**_).

Thanks in advance,  
Namita

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [May 19, 2022, 9:34am UTC](https://discuss.elastic.co/t/elastic-apm-with-asp-net-and-iis-server-configuration/305135/2 "2022-05-19T09:34:32Z")

</div>

> Is there a way to configure the application without making changes in the application, Like the way we have it in the aspnet core applications with zero code changes method of configuration.

Yes, there is. We have a profiler based agent in beta current which covers your use case. You can see the docs here: [Profiler Auto instrumentation | APM .NET Agent Reference [1.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup-auto-instrumentation.html)

Regarding you question about configs: the agent will by default read configs through environment variables - the environment variables for each config can be found in the docs. So that should work - have you tried that?

---

<div class="post-metadata">

**Author:** ![Namita\_Jaokar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/namita_jaokar/32/104106_2.png) [@Namita\_Jaokar](https://discuss.elastic.co/u/Namita_Jaokar)\
**Post date:** [May 19, 2022, 12:51pm UTC](https://discuss.elastic.co/t/elastic-apm-with-asp-net-and-iis-server-configuration/305135/3 "2022-05-19T12:51:44Z")

</div>

Hi @GregKalapos ,

Thankyou for providing me with the link for reference.

I have tried setting up the configuration for my netcore application. However , The application service is not visible in kibana.

I have followed below steps:

Downloaded and unizpped the beta version of the profiler.  
Tried setting the environment variable through appcmd.exe via powershell  
Below is the screenshot of the same:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/5/753cf5dbfd04e1c4f87201702c1a7f9c93d7ab75.png)

Performed IIS stop and start  
net stop /y was  
net start w3svc

Reloaded the application and performed few transactions. After performing few transactions as well , the service is not visible in kibana.

Could you please advise on the same. Please do let me know if at all I have missed out on any of the steps required.

Thankyou in advance,  
Namita

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [May 19, 2022, 1:14pm UTC](https://discuss.elastic.co/t/elastic-apm-with-asp-net-and-iis-server-configuration/305135/4 "2022-05-19T13:14:52Z")

</div>

Oh, sorry, I maybe misunderstood.

So, here is what setups we currently offer:

- [ASP.NET](http://ASP.NET) Classic on top of old .NET Framework running on IIS: [Configuration on ASP.NET | APM .NET Agent Reference [1.12] | Elastic](https://www.elastic.co/guide/en/apm/agent/dotnet/current/configuration-on-asp-net.html) with minor code change needed
- [ASP.NET](http://ASP.NET) Core (on top of netcoreapp) with minor code change: [Configuration on ASP.NET Core | APM .NET Agent Reference [1.12] | Elastic](https://www.elastic.co/guide/en/apm/agent/dotnet/current/configuration-on-asp-net-core.html)
- [ASP.NET](http://ASP.NET) Core (on top of netcoreapp) with zero code change: [.NET Core | APM .NET Agent Reference [1.12] | Elastic](https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup-dotnet-net-core.html#zero-code-change-setup)
- Profiler, which currently supports [ASP.NET](http://ASP.NET) Classic on top of .NET Framework running in IIS with zero code change.

Now, very important: the profiler currently does not support [ASP.NET](http://ASP.NET) Core running on netcoreapp (or well, it does, but there is a missing feature to automatically start the transaction - we want to cover this later, actually I'm working on this now..) - regardless of where the application runs.

So, from what you write it seems you have an [ASP.NET](http://ASP.NET) Core application on top of netcoreapp which you run in IIS. Is that correct? If that's the case then the zero code change setup with the startuphook method should work (and not the profiler at this point): [.NET Core | APM .NET Agent Reference [1.12] | Elastic](https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup-dotnet-net-core.html#zero-code-change-setup).

If that does not work, then we'll need to see what's going on, but probably that'd be the right way to go. Can you maybe collect logs from that setup? There is also a short troubleshooting section here which tells you how to collect logs form the loader: [apm-agent-dotnet/src/ElasticApmAgentStartupHook at main · elastic/apm-agent-dotnet · GitHub](https://github.com/elastic/apm-agent-dotnet/tree/main/src/ElasticApmAgentStartupHook#troubleshooting) - just do `set ELASTIC_APM_STARTUP_HOOKS_LOGGING=1` - could you please give this a try and see if there is something relevant in those logs?

---

<div class="post-metadata">

**Author:** ![Namita\_Jaokar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/namita_jaokar/32/104106_2.png) [@Namita\_Jaokar](https://discuss.elastic.co/u/Namita_Jaokar)\
**Post date:** [May 19, 2022, 1:43pm UTC](https://discuss.elastic.co/t/elastic-apm-with-asp-net-and-iis-server-configuration/305135/5 "2022-05-19T13:43:53Z")

</div>

@GregKalapos

Thanks a lot for providing such detailed information. 👍  
Yes, I was trying to configure [ASP.net](http://ASP.net) Core application on IIS. I have tried out with zero code changes that uses startuphook method and its working fine.

Hence moved further checking with IIS.

Also, The link provided for [asp.net](http://asp.net) on can be done in 2 ways  
by adding elasticapm in web.config **OR**  
by adding ELASTIC\_APM\_FULL\_FRAMEWORK\_CONFIGURATION\_READER\_TYPE in environment variable.

Any one of the above will do or I'll have to configure both in web.config as well as environment variables.  
Please correct my understanding on above.

Thanks in advance,  
Namita

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [May 19, 2022, 2:47pm UTC](https://discuss.elastic.co/t/elastic-apm-with-asp-net-and-iis-server-configuration/305135/6 "2022-05-19T14:47:58Z")

</div>

Oh - if you have a setup with the startuphook method which works for your [ASP.NET](http://ASP.NET) Core app on top of `netcoreapp`, then you don't need the IIS module.

I see how this can be confusing... but Microsoft created so many .NET versions over the last decades 🙂

So, even if your [ASP.NET](http://ASP.NET) Core app runs in IIS, the way to turn on the agent will be the one described in the zero code change setup: [.NET Core | APM .NET Agent Reference [1.12] | Elastic](https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup-dotnet-net-core.html#zero-code-change-setup)

In that case you can just ignore the IIS related docs we have - you won't really get anything more out of the app by adding it. That doc is specifically for [ASP.NET](http://ASP.NET) Classic on .NET Full Framework which can only be deployed in IIS - so that's the tech stack which pre-dates [ASP.NET](http://ASP.NET) Core.

You can run [ASP.NET](http://ASP.NET) Core apps on IIS as well, but for that setup you won't need our IIS module.

So, what's exactly your goal? If it already works with startuphook, then it should work in IIS and that'd be the preferred way to enable the agent with zero code change for [ASP.NET](http://ASP.NET) Core in that setup.

Or do I misunderstand something and something does not work for you?

---

<div class="post-metadata">

**Author:** ![Namita\_Jaokar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/namita_jaokar/32/104106_2.png) [@Namita\_Jaokar](https://discuss.elastic.co/u/Namita_Jaokar)\
**Post date:** [May 20, 2022, 11:20am UTC](https://discuss.elastic.co/t/elastic-apm-with-asp-net-and-iis-server-configuration/305135/7 "2022-05-20T11:20:27Z")

</div>

I had tried the startuphook method by declaring the environment variables required in a shell and then triggered it along with the standalone netcoreapp executable.

Today , I declared them in my system's environment variables and deployed the executable in the IIS. **That did work** 🙂  
I am able to get the traces now.

Thanks alot! 👍

Best Regards,  
Namita

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 10, 2022, 7:21am UTC](https://discuss.elastic.co/t/elastic-apm-with-asp-net-and-iis-server-configuration/305135/8 "2022-06-10T07:21:23Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
