diff --git a/src/Helpers/SortedHtmlDirectoryFormatter.cs b/src/Helpers/SortedHtmlDirectoryFormatter.cs
new file mode 100644
index 00000000..ea6fe671
--- /dev/null
+++ b/src/Helpers/SortedHtmlDirectoryFormatter.cs
@@ -0,0 +1,16 @@
+using System.Text.Encodings.Web;
+using Microsoft.AspNetCore.StaticFiles;
+using Microsoft.Extensions.FileProviders;
+
+namespace LocalTest.Helpers;
+
+public class SortedHtmlDirectoryFormatter : HtmlDirectoryFormatter
+{
+ public SortedHtmlDirectoryFormatter() : base(HtmlEncoder.Default) { }
+
+ public override Task GenerateContentAsync(HttpContext context, IEnumerable contents)
+ {
+ var sorted = contents.OrderByDescending(f => f.LastModified);
+ return base.GenerateContentAsync(context, sorted);
+ }
+}
diff --git a/src/Startup.cs b/src/Startup.cs
index d56f2c37..ef5c1203 100644
--- a/src/Startup.cs
+++ b/src/Startup.cs
@@ -23,6 +23,7 @@
using AltinnCore.Authentication.JwtCookie;
using LocalTest.Clients.CdnAltinnOrgs;
using LocalTest.Configuration;
+using LocalTest.Helpers;
using LocalTest.Services.Authentication.Implementation;
using LocalTest.Services.Authentication.Interface;
using LocalTest.Services.Authorization.Implementation;
@@ -208,7 +209,8 @@ public void Configure(
app.UseDirectoryBrowser(new DirectoryBrowserOptions
{
FileProvider = new PhysicalFileProvider(localPlatformSettings.Value.LocalTestingStorageBasePath),
- RequestPath = "/LocalPlatformStorage"
+ RequestPath = "/LocalPlatformStorage",
+ Formatter = new SortedHtmlDirectoryFormatter(),
});
app.UseStaticFiles();