using the following code
context.Response.StatusCode = 301;
context.Response.Redirect(newUrl, true);
context.Response.End();
I can see in
Response.Redirect() will overwrite the StatusCode property with the code for a redirect (302). Also, because you're using the Response.Redirect() overload taking the boolean parameter, you should set it to False if you want to call Response.End() yourself. Otherwise it's redundant and can cause errors.
Try the following (pre-ASP.NET 4.0; Adam Butler's answer covers the new best practice):
context.Response.Redirect(newUrl, false);
context.Response.StatusCode = 301;
context.Response.End();