Event log source Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer with Invalid URI

Ryan Pureber asked on March 7, 2025 22:33

I am getting the following event log error on a production site. This does not occur on any other environment (dev, QA or stage). It occurs almost every day if not every day. Sometimes it's once a day, other times it is a couple dozen times. Sometimes it will occur every few seconds, then maybe not for a couple of hours.

EventID: 52560986

EventType: E

EventTime: 2/26/2025 9:47:25 PM

Source: Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer

EventCode: 0

EventDescription: Unexpected exception in IISHttpContext.HandleRequest. Message: An error occurred while writing to logger(s). (Invalid URI: The format of the URI could not be determined.)

Exception type: System.AggregateException Stack trace: at Microsoft.Extensions.Logging.Logger.ThrowLoggingError(List'1 exceptions) at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func'3 formatter) at Microsoft.Extensions.Logging.Logger'1.Microsoft.Extensions.Logging.ILogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func'3 formatter) at Microsoft.Extensions.Logging.LoggerMessage.<>c__DisplayClass12_0'2.g__Log|0(ILogger logger, T1 arg1, T2 arg2, Exception exception) at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.Log.ApplicationError(ILogger logger, String connectionId, String traceIdentifier, Exception ex) at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT'1.ProcessRequestAsync() at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT'1.ProcessRequestAsync() at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContext.HandleRequest()

Message: Invalid URI: The format of the URI could not be determined.

Exception type: System.UriFormatException Stack trace: at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions) at System.Uri..ctor(String uriString) at CMS.Helpers.RequestContext.get_URLReferrer() at CMS.EventLog.EventLogService.LogEvent(EventLogData eventLogData) at Kentico.Web.Mvc.KenticoEventLogLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter) at Microsoft.Extensions.Logging.Logger.g__LoggerLog|14_0[TState](LogLevel logLevel, EventId eventId, ILogger logger, Exception exception, Func'3 formatter, List'1& exceptions, TState& state)

EventMachineName: Matches web server name in system

Recent Answers


Juraj Ondrus answered on March 10, 2025 05:37

We are not familiar with this error as it is coming from the live site app - which we do not know what is its setup, code, configuration - way too many unknown variables for us. You also did not mentioned what are the actions leading to this error, what troubleshooting you have done so far, etc. For example, there are many discussions on this error on Stackoverflow - have you tried checking them yet?

https://stackoverflow.com/questions/61691648/c-sharp-invalid-uri-the-format-of-the-uri-could-not-be-determined

https://port135.com/invalid-uri-the-format-of-the-uri-could-not-be-determined/

https://stackoverflow.com/questions/2887924/invalid-uri-the-format-of-the-uri-could-not-be-determined

I would check the IIS setup, bindings and then also the URLs set as presentation URL in Kentico app. What were the most recent changes made before this issue started? Are there any other errors? Are you using Kentico API in any external app - to get pages, custom table items, or other data? Maybe there is some invalid URI specified somewhere.

This sounds like there is some error being thrown, Kentico wants to log it but fails because of invalid URI.

We would need to know how to reproduce the issue using out of the box Kentico installation and Dancing Goat project - this is what we have on our side, what we delivered to you. We do not know your changes so we really need more details than just a copy of an error.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.