From ff5e914a3c14238a6751f1f657e48b06fdabca56 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Mon, 30 Mar 2026 20:13:58 +0200 Subject: [PATCH] Fix WireMock.Net.WebApplication.IIS example --- .../WireMock.Net.WebApplication.IIS/App.cs | 17 +++----------- .../Program.cs | 4 ---- .../WireMock.Net.WebApplication.IIS.csproj | 1 - .../WireMockService.cs | 2 -- .../appsettings.json | 2 +- .../web.config | 23 +++++++++++-------- 6 files changed, 18 insertions(+), 31 deletions(-) diff --git a/examples/WireMock.Net.WebApplication.IIS/App.cs b/examples/WireMock.Net.WebApplication.IIS/App.cs index d9ac8caa..85c45de0 100644 --- a/examples/WireMock.Net.WebApplication.IIS/App.cs +++ b/examples/WireMock.Net.WebApplication.IIS/App.cs @@ -1,29 +1,18 @@ // Copyright © WireMock.Net -using Microsoft.Extensions.Hosting; -using System.Threading; -using System.Threading.Tasks; - namespace WireMock.Net.WebApplication; -public class App : IHostedService +public class App(IWireMockService service) : IHostedService { - private readonly IWireMockService _service; - - public App(IWireMockService service) - { - _service = service; - } - public Task StartAsync(CancellationToken cancellationToken) { - _service.Start(); + service.Start(); return Task.CompletedTask; } public Task StopAsync(CancellationToken cancellationToken) { - _service.Stop(); + service.Stop(); return Task.CompletedTask; } } \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication.IIS/Program.cs b/examples/WireMock.Net.WebApplication.IIS/Program.cs index 4759d47e..c4bada0a 100644 --- a/examples/WireMock.Net.WebApplication.IIS/Program.cs +++ b/examples/WireMock.Net.WebApplication.IIS/Program.cs @@ -1,9 +1,5 @@ // Copyright © WireMock.Net -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; using WireMock.Settings; namespace WireMock.Net.WebApplication; diff --git a/examples/WireMock.Net.WebApplication.IIS/WireMock.Net.WebApplication.IIS.csproj b/examples/WireMock.Net.WebApplication.IIS/WireMock.Net.WebApplication.IIS.csproj index f7a28618..de231084 100644 --- a/examples/WireMock.Net.WebApplication.IIS/WireMock.Net.WebApplication.IIS.csproj +++ b/examples/WireMock.Net.WebApplication.IIS/WireMock.Net.WebApplication.IIS.csproj @@ -15,7 +15,6 @@ - diff --git a/examples/WireMock.Net.WebApplication.IIS/WireMockService.cs b/examples/WireMock.Net.WebApplication.IIS/WireMockService.cs index d35f9c97..249ddb9b 100644 --- a/examples/WireMock.Net.WebApplication.IIS/WireMockService.cs +++ b/examples/WireMock.Net.WebApplication.IIS/WireMockService.cs @@ -1,7 +1,5 @@ // Copyright © WireMock.Net -using System; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Newtonsoft.Json; using WireMock.Admin.Requests; diff --git a/examples/WireMock.Net.WebApplication.IIS/appsettings.json b/examples/WireMock.Net.WebApplication.IIS/appsettings.json index 6c3ec0b9..b0d90528 100644 --- a/examples/WireMock.Net.WebApplication.IIS/appsettings.json +++ b/examples/WireMock.Net.WebApplication.IIS/appsettings.json @@ -15,7 +15,7 @@ "WireMockServerSettings": { "StartAdminInterface": true, "Urls": [ - "http://localhost" + "http://localhost:0" ] } } diff --git a/examples/WireMock.Net.WebApplication.IIS/web.config b/examples/WireMock.Net.WebApplication.IIS/web.config index 1805fd75..b405411c 100644 --- a/examples/WireMock.Net.WebApplication.IIS/web.config +++ b/examples/WireMock.Net.WebApplication.IIS/web.config @@ -1,12 +1,17 @@ - + - - - - - - - + --> + + + + + + + + + + + \ No newline at end of file