poppastring / dasblog-core

The original DasBlog reimagined with ASP.NET Core
MIT License
469 stars 193 forks source link

[Bug] The Uri string is too long #690

Closed Tdue21 closed 9 months ago

Tdue21 commented 10 months ago

I set up a blog site a while back using dasblog 3.3.1038.0. It worked perfectly. Today, I returned for a dinner recipe I have on the blog, and I get this:

image

Looking in the log file, I see this exception:

2023-09-09 14:51:32.557 +02:00 [Error] Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware: An unhandled exception has occurred while executing the request.
System.UriFormatException: Invalid URI: The Uri string is too long.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri.CreateUri(Uri baseUri, String relativeUri, Boolean dontEscape)
   at System.Uri..ctor(Uri baseUri, String relativeUri)
   at DasBlog.Web.Settings.DasBlogSettings.RelativeToRoot(String relative) in C:\Development\Forks\dasblog-core\source\DasBlog.Web.UI\Settings\DasBlogSettings.cs:line 86
   at DasBlog.Web.Settings.DasBlogBaseController.SinglePost(PostViewModel post) in C:\Development\Forks\dasblog-core\source\DasBlog.Web.UI\Controllers\DasBlogBaseController.cs:line 68
   at DasBlog.Web.Settings.DasBlogBaseController.SinglePostView(ListPostsViewModel listPostsViewModel) in C:\Development\Forks\dasblog-core\source\DasBlog.Web.UI\Controllers\DasBlogBaseController.cs:line 31
   at DasBlog.Web.Controllers.BlogPostController.Post(String posttitle, String day, String month, String year) in C:\Development\Forks\dasblog-core\source\DasBlog.Web.UI\Controllers\BlogPostController.cs:line 95
   at lambda_method145(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at DasBlog.Web.Services.LoggingAgent.Invoke(HttpContext context) in C:\Development\Forks\dasblog-core\source\DasBlog.Web.UI\Services\LoggingAgent.cs:line 50
   at DasBlog.Web.Startup.<>c.<<Configure>b__20_9>d.MoveNext() in C:\Development\Forks\dasblog-core\source\DasBlog.Web.UI\Startup.cs:line 398
--- End of stack trace from previous location ---
   at NWebsec.AspNetCore.Middleware.Middleware.CspMiddleware.Invoke(HttpContext context)
   at NWebsec.AspNetCore.Middleware.Middleware.MiddlewareBase.Invoke(HttpContext context)
   at NWebsec.AspNetCore.Middleware.Middleware.MiddlewareBase.Invoke(HttpContext context)
   at NWebsec.AspNetCore.Middleware.Middleware.MiddlewareBase.Invoke(HttpContext context)
   at NWebsec.AspNetCore.Middleware.Middleware.MiddlewareBase.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at NWebsec.AspNetCore.Middleware.Middleware.MiddlewareBase.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

To the best of my knowledge, nothing has changed on the blog in a while. The site is hosted though, so of course it is possible something changed in the environment.

Everything seems to work fine, except whenever I click on a specific blog post, then I get this error.

Tdue21 commented 10 months ago

As an experiment I added a new blog post, and I can open that without problems. I don't see any significant difference between the blog post failing and the new one, when I look in the content folder. Except the content, of course.

Tdue21 commented 9 months ago

Hm. Apparently the issue is caused by the embedded images. Each faulty blog post had an embedded image, defined like this:

<img src="data:image/png;base64,...">

Once I removed the images from the blog posts and added them as linked images instead, everything worked as it should.