Reorder middleware so that site context is loaded first

In certain cases, such as a non-existent site, the request.view_requests
attribute was missing, causing errors.