diff --git a/Directory.Packages.props b/Directory.Packages.props
index 5851fbf9..fc38d7a2 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -22,6 +22,8 @@
+
+
diff --git a/EssentialCSharp.Web/EssentialCSharp.Web.csproj b/EssentialCSharp.Web/EssentialCSharp.Web.csproj
index 7932dbef..f0a2c6e2 100644
--- a/EssentialCSharp.Web/EssentialCSharp.Web.csproj
+++ b/EssentialCSharp.Web/EssentialCSharp.Web.csproj
@@ -38,6 +38,7 @@
+
diff --git a/EssentialCSharp.Web/Program.cs b/EssentialCSharp.Web/Program.cs
index 10829c7a..48094a92 100644
--- a/EssentialCSharp.Web/Program.cs
+++ b/EssentialCSharp.Web/Program.cs
@@ -19,6 +19,7 @@
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.AspNetCore.RateLimiting;
using Azure.Monitor.OpenTelemetry.AspNetCore;
+using Azure.Monitor.OpenTelemetry.Profiler;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
@@ -90,7 +91,7 @@ private static void Main(string[] args)
});
if (useAzureMonitor)
- otel.UseAzureMonitor();
+ otel.UseAzureMonitor().AddAzureMonitorProfiler();
else if (useOtlp)
otel.UseOtlpExporter();
@@ -511,7 +512,7 @@ await McpJsonRpcResponseWriter.WriteErrorAsync(
}
app.UseStaticFiles();
- app.UseRouting();
+ app.UseRouting();
app.UseWhen(
context => context.Request.Path.StartsWithSegments("/mcp"),
@@ -542,10 +543,10 @@ await McpJsonRpcResponseWriter.WriteErrorAsync(
await next(context);
}));
- app.UseRateLimiter();
-
- app.UseAuthorization();
- app.UseOutputCache();
+ app.UseRateLimiter();
+
+ app.UseAuthorization();
+ app.UseOutputCache();
app.UseMiddleware();
@@ -584,13 +585,23 @@ await McpJsonRpcResponseWriter.WriteErrorAsync(
try
{
SitemapXmlHelpers.EnsureSitemapHealthy(siteMappingService.SiteMappings.ToList());
- LogSitemapValidationSucceeded(logger);
- }
- catch (Exception ex)
- {
- LogSitemapValidationFailed(logger, ex);
- // Continue startup even if sitemap validation fails
- }
+ LogSitemapValidationSucceeded(logger);
+ }
+ catch (InvalidOperationException ex)
+ {
+ LogSitemapValidationFailed(logger, ex);
+ // Continue startup even if sitemap validation fails
+ }
+ catch (ArgumentException ex)
+ {
+ LogSitemapValidationFailed(logger, ex);
+ // Continue startup even if sitemap validation fails
+ }
+ catch (FormatException ex)
+ {
+ LogSitemapValidationFailed(logger, ex);
+ // Continue startup even if sitemap validation fails
+ }
app.Run();
}
@@ -604,11 +615,11 @@ private static bool IsMcpTransportRequest(HttpRequest request) =>
[LoggerMessage(Level = LogLevel.Error, Message = "Unhandled exception on {Path}")]
private static partial void LogUnhandledException(ILogger logger, Exception? exception, PathString path);
- [LoggerMessage(Level = LogLevel.Information, Message = "Sitemap validation completed successfully during application startup")]
- private static partial void LogSitemapValidationSucceeded(ILogger logger);
-
- [LoggerMessage(Level = LogLevel.Error, Message = "Failed to validate sitemap during application startup")]
- private static partial void LogSitemapValidationFailed(ILogger logger, Exception exception);
+ [LoggerMessage(Level = LogLevel.Information, Message = "Sitemap validation completed successfully during application startup")]
+ private static partial void LogSitemapValidationSucceeded(ILogger logger);
+
+ [LoggerMessage(Level = LogLevel.Error, Message = "Failed to validate sitemap during application startup")]
+ private static partial void LogSitemapValidationFailed(ILogger logger, Exception exception);
[LoggerMessage(Level = LogLevel.Warning, Message = "Ignoring invalid TryDotNet origin in CSP: {Origin}")]
private static partial void LogIgnoringInvalidTryDotNetOrigin(ILogger logger, string origin);
diff --git a/EssentialCSharp.Web/appsettings.Development.json b/EssentialCSharp.Web/appsettings.Development.json
index f7e1d576..08db179d 100644
--- a/EssentialCSharp.Web/appsettings.Development.json
+++ b/EssentialCSharp.Web/appsettings.Development.json
@@ -3,7 +3,9 @@
"Logging": {
"LogLevel": {
"Default": "Information",
- "Microsoft.AspNetCore": "Warning"
+ "Microsoft.AspNetCore": "Warning",
+ "Microsoft.ServiceProfiler": "Debug",
+ "Azure.Monitor.OpenTelemetry.Profiler": "Debug"
}
},
"ConnectionStrings": {