Mam HttpHandler z następującego kodu:Ustawienie Context.Response.StatusCode nie wydają się działać
using System;
using System.Web;
using Company.Cms;
using Company.Web.Handlers.Console;
namespace Company.Web.Handlers
{
/// <summary>
/// Summary description for AdminHandler
/// </summary>
public class AdminHandler : IHttpHandler
{
public bool IsReusable
{
get
{
return false;
}
}
public void ProcessRequest(HttpContext context)
{
HttpRequest request = context.Request;
HttpResponse response = context.Response;
string action = request.QueryString["action"];
if (!HttpContext.Current.User.CanAdminister())
{
response.StatusCode = 403;
response.Status = "403 Access Denied";
response.End();
return;
}
if (String.IsNullOrEmpty(action))
{
response.StatusCode = 404;
response.Status = "404 Not Found";
response.End();
return;
}
IHttpHandler handler = null;
switch (action)
{
case "menu":
handler = new MenuHandler();
break;
case "tree":
handler = new TreeHandler();
break;
case "grid":
handler = new GridHandler();
break;
case "list":
handler = new ListHandler();
break;
case "drop":
handler = new DropHandler();
break;
case "edit":
handler = new EditHandler();
break;
case "new":
handler = new InsertHandler();
break;
}
if (handler == null)
{
response.StatusCode = 404;
response.Status = "404 Not Found";
response.End();
}
else
{
handler.ProcessRequest(context);
}
}
}
}
Niestety kiedy celowo podać nieprawidłową akcję, przeglądarka wyświetla tylko pustą stronę. Brak komunikatów o błędach przeglądarki jest wyświetlany zarówno w Firefoksie, jak i IE.
Co mogę zrobić źle?
EDIT - IE pokazuje komunikat o błędzie, ale Firefox go nie obsługuje.
Co Firebug/Fiddler powie Ci o odpowiedzi? – Oded
Firebug pokazuje poprawny status. Czy to oznacza, że jeśli chcę, aby przeglądarka wyświetlała komunikat, muszę go renderować? –