Skip to content

Commit 2efe235

Browse files
committed
[fix] PreviousPageUrlUpdater dependency resolution at startup
1 parent ab95824 commit 2efe235

6 files changed

Lines changed: 18 additions & 6 deletions

File tree

src/SampleApps/SampleApp.Classic/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"StaticFilesPaths": "styles, scripts, images, content, fonts, node_modules",
66
"ErrorPageDarkStyle": true,
77
"MeasurementsEnabled": true,
8-
"ConsoleTracing": true
8+
"ConsoleTracing": true,
9+
"EnablePreviousPageUrlUpdate": true
910
}
1011
}

src/Simplify.Web.Tests/Controllers/Execution/PreviousPageUrlUpdaterTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@ public class PreviousPageUrlUpdaterTests
1919

2020
private Mock<IControllersExecutor> _baseExecutor = null!;
2121
private Mock<IRedirector> _redirector = null!;
22+
private Mock<IWebContextProvider> _webContextProvider = null!;
2223
private Mock<IWebContext> _webContext = null!;
2324

2425
[SetUp]
2526
public void Initialize()
2627
{
2728
_baseExecutor = new Mock<IControllersExecutor>();
2829
_redirector = new Mock<IRedirector>();
30+
_webContextProvider = new Mock<IWebContextProvider>();
2931
_webContext = new Mock<IWebContext>();
3032

3133
_webContext.SetupGet(x => x.Response).Returns(new Mock<HttpResponse>().Object);
34+
_webContextProvider.Setup(x => x.Get()).Returns(_webContext.Object);
3235

33-
_updater = new PreviousPageUrlUpdater(_baseExecutor.Object, _redirector.Object, _webContext.Object);
36+
_updater = new PreviousPageUrlUpdater(_baseExecutor.Object, _redirector.Object, _webContextProvider.Object);
3437
}
3538

3639
[Test]

src/Simplify.Web/Bootstrapper/Setup/BaseBootstrapperControllersExecution.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public virtual void RegisterControllersExecutor()
6868
new PreviousPageUrlUpdater(
6969
r.Resolve<ControllersExecutor>(),
7070
r.Resolve<IRedirector>(),
71-
r.Resolve<IWebContext>()));
71+
r.Resolve<IWebContextProvider>()));
7272
else
7373
BootstrapperFactory.ContainerProvider.Register<IControllersExecutor>(r => r.Resolve<ControllersExecutor>());
7474
}

src/Simplify.Web/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## [5.7.1] - 2026-07-24
4+
5+
### Fixed
6+
7+
- `PreviousPageUrlUpdater`: use `IWebContextProvider` instead of resolving
8+
`IWebContext` directly from the container, fixing a resolution failure
9+
(`Error.UnableToResolveUnknownService`) at startup.
10+
311
## [5.7.0] - 2026-07-24
412

513
### Added

src/Simplify.Web/Controllers/Execution/PreviousPageUrlUpdater.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Simplify.Web.Controllers.Execution;
99
/// Provides the previous page URL updater
1010
/// </summary>
1111
/// <seealso cref="IControllersExecutor" />
12-
public class PreviousPageUrlUpdater(IControllersExecutor baseExecutor, IRedirector redirector, IWebContext webContext) : IControllersExecutor
12+
public class PreviousPageUrlUpdater(IControllersExecutor baseExecutor, IRedirector redirector, IWebContextProvider webContextProvider) : IControllersExecutor
1313
{
1414
/// <summary>
1515
/// Executes the controllers asynchronously.
@@ -19,7 +19,7 @@ public async Task<ResponseBehavior> ExecuteAsync(IReadOnlyList<IMatchedControlle
1919
{
2020
var result = await baseExecutor.ExecuteAsync(controllers);
2121

22-
if (result == ResponseBehavior.Default && !webContext.Response.HasStarted)
22+
if (result == ResponseBehavior.Default && !webContextProvider.Get().Response.HasStarted)
2323
redirector.SetPreviousPageUrlToCurrentPage();
2424

2525
return result;

src/Simplify.Web/Simplify.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1010
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1111

12-
<Version>5.7</Version>
12+
<Version>5.7.1</Version>
1313

1414
<Description>Lightweight and fast .NET web-framework based on MVC and OWIN</Description>
1515
<Product>Simplify</Product>

0 commit comments

Comments
 (0)