Developer forum

Forum » Dynamicweb 10 » 10.8 Error: Invalid ascii character in header

10.8 Error: Invalid ascii character in header

Jóhannes Þorkell Tómasson
Reply

Hi.

I ran into an amusing error that seems to be 10.8 related. When receiving callbacks in the CheckouHandler.HandleRequest method I got an exception that there is an "Invalid ascii character in header" which crashed the site. This only happened in my local dev environment and it started seemingly out of nowhere when everything had been working fine before. I debugged it and since it was only local with the same code that runs on our test and prod environments I thought it could be a server issue so I switched from Kestrel to httpsys and voilà it started working again. I didn't think much of it until some days later, having switched back to Kestrel for other development, the error was gone. I realised that I had been trying different versions of DW going from 10.7 -> 10.8 and back. So I kept everything else the same and only changed the DW versions and the crash only happened when using DW 10.8 (tested for both 10.8.0 and 10.8.1) in combination with Kestrel.

So maybe not a very important error but I found it quite funny!

BR, Jóhannes 


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Johannes

That is an odd one. I think I might know what that can be.

In 10.8 we added a redirectreason so that you sometimes will receive a "X-DWAPP-REDIR-REASON" header with the reason for the redirect.

One of the reasons that you can encounter in that heading is "PageViewHandlerMiddleware incoming path ends with /" and that last / could be causing this issue.

An alternative can also be that we try to do a redirect to something that is a URL with non-ascii characters related to this issue in asp.net: https://github.com/dotnet/aspnetcore/issues/4919
This issue indicates that we should url encode something we are currently not when performing the redirect.

So if you have a chance to verify one of these theories:

  1. You go to a page with somehost.tld/home/ (note the ending /) and gets a redirect to /home in httpsys, but an exception on kestrel
  2. You are using Icelandic or other non-ascii characters in parts of the URL and some URL settings in DW causes a redirect from e.g. Default.aspx?ID=123 to /hølå or similar redirect.

BR Nicolai

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Note to self - you are experiencing this in a callback. Might be a little different, but callbacks might also cause redirects.... Do you have the full callback URL to share?

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

And do you do a custom checkouthandler? And what happens in the HandleRequest override?

 
Jóhannes Þorkell Tómasson
Reply

Hi again.

The error occurs on a redirect from Netgíró payment services when an order has been paid for. We have a custom checkouhandler for Netgíró. The request that causes the error never actually reaches the HandleRequest method, which makes sense since it seems to be related to how Kestrel parses the url. Here is an example full url for the actual request to DW (i.e. browser has recieved the redirect response from Netgírós servers and requests the url from it's location header):

https://marcopolo.local.dynamicweb.dk:7773/Default.aspx?ID=1844
&CheckoutHandlerOrderID=ORDER997
&CallbackType=CB_SUCCESS
&transactionid=9f193313-13d4-450b-af26-501732e2dab6
&referenceNumber=ORDER997
&invoiceNumber=844333
&status=2
&accountNumber=500004
&orderid=ORDER997
&confirmationCode=9f193313-13d4-450b-af26-501732e2dab6
&success=True
&paymentCode=200
&netgiroSignature=6f5c5bd9279c2e3b3888ffafbb20aa07a4dd0b56d86beeb9163f0c076b2e751d
&totalAmount=14392
&signature=59253a07a901860245ed198b5dffcaf0a660b1020fc539469ff02c941c1ddf7f
&name=-
&email=-
&paymentSuccessful=True
&address=Some+Address+10
&address2=
&city=Reykjav%c3%adk
&country=Iceland
&zip=111

I prettyprinted the url, it contains no linebreaks in actuality (obviously :)).

Here is a screenshot of the dev exception page:

...Looking further into this now, the 0x00ED character it's complaining about is the unicode encoding for the icelandic "í" character. The url query param "city" has the value Reykjav%c3%adk which is a proper url encoding of Reykjavík. Despite the encoding being correct this would be a mighty coincidence if it's unrelated :).

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Yikes... We will try to have a look at this, if we can reproduce and do something about it....

Votes for this answer: 1

 

You must be logged in to post in the forum