turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

System.UriFormatException: Invalid URI: The hostname could not be parsed. #345

Closed rafaeldruiz closed 7 years ago

rafaeldruiz commented 7 years ago

I'm receiving the error below catched by Elmah:

System.UriFormatException: Invalid URI: The hostname could not be parsed.

Generated: Fri, 16 Jun 2017 14:21:39 GMT

System.UriFormatException: Invalid URI: The hostname could not be parsed. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) at System.Web.Util.UriUtil.BuildUriImpl(String scheme, String serverName, String port, String path, String queryString, Boolean useLegacyRequestUrlGeneration) at System.Web.HttpRequest.BuildUrl(Func`1 pathAccessor) at System.Web.HttpRequest.get_Url() at i18n.EarlyUrlLocalizer.ProcessIncoming(HttpContextBase context) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I don't have any information on how to reproduce it, but the problem seems to be in the i18n localizer.

turquoiseowl commented 7 years ago

I've not seen that before. Looks like and edge condition in which i18n EarlyUrlLocalizer filter needs to ignore the request (and thereby not access the Request.Url property). Any idea what the condition is, URL is etc.? Probably down to you to debug it.

rafaeldruiz commented 7 years ago

No idea. I received this error twice on live environment reported by Elmah. There was no info about the URL executed or any other parameter.

That's why I opened the issue here.

I don't know how i18n creates the url, but you could try using Uri.TryCreate.

turquoiseowl commented 7 years ago

Cannot fix without more information. Please re-open if any is forthcoming. Thanks.