Categories
Development

How to configure Application Insights sampling on Net Core HostBuilder?

I’m building .Net Core background service, using ApplicationInsights.WorkerService nuget package. The documentation regarding sampling configuration says to refer to this: https://docs.microsoft.com/en-us/azure/azure-monitor/app/sampling#configure-sampling-settings And it shows this: public void Configure(IApplicationBuilder app, IHostingEnvironment env, TelemetryConfiguration configuration) { var builder = configuration.DefaultTelemetrySink.TelemetryProcessorChainBuilder; // For older versions of the Application Insights SDK, use the following line instead: // var builder […]

Categories
Development

Specific Log to specific files using Nlog in .Net core 2.2

I have successfully configured NLog in .net core 2.2 web api. But I wanted to achieve specifications with logging. How to achieve below: Warnings should be logged to warn specific file Errors should be logged to error specific file When I log request/response that file should only consist of my requests But currently with request […]

Categories
Development MVC

A single login page for multiple authentication types (including Azure AD) in .NET Core MVC

I have a .NET Core 2.2 MVC web-application. And I’ve added two authentication types/providers there: Login/password with local users database (custom thing, without .NET Core Identity) Azure AD My goal is to have a login page at /account/login where users can choose between these two authentications and log-in with either of those. So every time […]

Categories
Development

How are the actions specified in AddRazorOptions or Configure

I’m trying to host my web application in service fabric, but my pages won’t load. I’ve determined it has something to do with my razor initialization. The code below shows my initialization sequence. The actions provided to AddRazorOptions and Configure() never execute. What call would trigger them? using System; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; […]

Categories
Development

Middleware with Masstransit publish

I have .net core WEB API application with MassTransit (for implement RabbitMQ message broker). RabbitMQ-MassTransit configuration is simple and done in few line code in Startup.cs file. services.AddMassTransit(x => { x.AddConsumer<CustomLogConsume>(); x.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(cfg => { var host = cfg.Host(new Uri(“rabbitmq://rabbitmq/”), h => { h.Username(“guest”); h.Password(“guest”); }); cfg.ExchangeType = ExchangeType.Fanout; cfg.ReceiveEndpoint(host, “ActionLog_Queue”, e => { […]

Categories
Development

Middleware with Masstransit publish

I have .net core WEB API application with MassTransit (for implement RabbitMQ message broker). RabbitMQ-MassTransit configuration is simple and done in few line code in Startup.cs file. services.AddMassTransit(x => { x.AddConsumer<CustomLogConsume>(); x.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(cfg => { var host = cfg.Host(new Uri(“rabbitmq://rabbitmq/”), h => { h.Username(“guest”); h.Password(“guest”); }); cfg.ExchangeType = ExchangeType.Fanout; cfg.ReceiveEndpoint(host, “ActionLog_Queue”, e => { […]

Categories
Development

.Net-Core 2.2 MassTransit.ConfigurationException: The state machine was not properly configured

Newbie question – what am I missing? Are there any dotnetcore 2.2 Saga examples available? I have a basic end to end system working OK with messages flowing across containers in docker-compose, but adding a Saga seems to be a challenge – Q. Am I missing a scheduler dependency? In MassTransit 5.5.5, cfg.UseInMemoryMessageScheduler(); doesn’t compile. […]

Categories
ASP.NET Development Windows

asp.net core web api work on iis express but not working in iis on windows

i am new in asp.net core. i use asp.net core 2.1. i have two controller. a default valuecontroller that doesn’t have db connection and customerController that have sqlserver db connection. when i run my project on iis express everything is good but when i publish my project and use windows iis value api work nice […]

Categories
Development MongoDB

Serilog doesn’t write on MongoDB and it doesn’t throw any errors

On my Web Api Net.Core 2.2 project, I needed to use serilog and I wanted to write log on my MongoDB instance on the cloud. Serilog has written correctly on the console and file but it didn’t on the MongoDB instance. Besides It didn’t throw or log any errors. How can I check what happend? […]

Categories
ASP.NET Development MVC

Asp.net Core MVC – obtaining dependency during app shutdown

I’m developing a web app using ASP.net Core MVC 2.2, and in my Startup class I’m registering a dependency injection of type MyService, like so: public void ConfigureServices(IServiceCollection services) { //Inject dependency services.AddSingleton<MyService>(); //…other stuff… } This works correctly. However, I need to retrieve the instance of MyService during application shutdown, in order to do […]