Nservicebus: ASP.Net MVC application rebuilding itself after every web request when SetDiagnosticsPath is used

Created on 27 Sep 2018  路  2Comments  路  Source: Particular/NServiceBus

When I used the .SetDiagnosticsPath() method within an ASP.Net MVC application, if I refresh the page or make a new request, the entire application rebuilds itself. This results in extremely poor performance and renders the web application completely unusable.

As a workaround, I added the following line whilst configuring my NSB endpoint:

endpointConfiguration.CustomDiagnosticsWriter(s => Task.CompletedTask);

I have a template application which exhibits this behaviour if it makes fixing this issue any easier, although you can add the following to any class in your App_Start folder:

var endpointConfiguration = new EndpointConfiguration("nsbEndpoint");
endpointConfiguration.SetDiagnosticsPath($@"{AppDomain.CurrentDomain.BaseDirectory}bin\.diagnostics");

endpointConfiguration.UseTransport<SqlServerTransport>().ConnectionString(cnnctnstrng);

endpointConfiguration.UsePersistence<InMemoryPersistence>();

Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult();

Then, try refreshing the page.

NSB, version 7.1.4
Transport: SQL Transport, version 4.1.0 (likely also happens on other transports)

Most helpful comment

@chipolatas It sounds like what you're experiencing is exactly why we don't use the bin folder by default when we detect you're running an ASP.NET application. We default to the App_Data folder instead.

The reason for this is that ASP.NET monitors the bin folder for changes and recompiles the application when anything changes.

If you don't want to use App_Data, you need to use SetDiagnosticsPath to point to some place other than your bin folder.

All 2 comments

@chipolatas It sounds like what you're experiencing is exactly why we don't use the bin folder by default when we detect you're running an ASP.NET application. We default to the App_Data folder instead.

The reason for this is that ASP.NET monitors the bin folder for changes and recompiles the application when anything changes.

If you don't want to use App_Data, you need to use SetDiagnosticsPath to point to some place other than your bin folder.

@bording ahh I wasn't aware ASP.NET did that... completely my fault! Thanks for the quick reply! :)

Was this page helpful?
0 / 5 - 0 ratings