Developer forum

Forum » Development » 404 handler taking long time

404 handler taking long time

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I am using the Standard.Page.NotFound subscriber to return a default image for 404 images. It goes like this (all pseudo code):

var request = GetUrlFrom404Request();
if (!request.Image()) { return; }
context.Response.Clear();
context.Response.BinaryWrite(request.GetImage());
context.ApplicationInstance.CompleteRequest();

This works well and serves up our default image for non-exiting images.

However, we're finding that this solution is really slow. Handling the 404 seems to take at least 3 or 4 seconds.

Is there other stuff going on before our OnNotify runs? Is there a way to tell the 404 handler that I already handled the request? It would be nice to have a IsHandled property on NotFoundArgs that would bypass any other processing when set to true.

Thanks!


Replies

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply
This post has been marked as an answer

Hi Imar,

Is the 404 also slow without any custom code? I can't reproduce that.
Is there any reason why you are not using getimage.ashx for this? That would skip a lot of the steps during request handling.
Another option you could try is to handle image requests on the AuthenticateRequest notification (where you can set Handled = true).

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks Morten. I tried AuthenticateRequest and it's working a lot faster!

 

You must be logged in to post in the forum