http-status-codes

Friendly HTTP 401 Status Code Message?

I'm a developer not a wordsmith and as such I'm stuck. We have a subscription based site whereby users may well come across our 401 page. We've decided that the IIS 401;2 page needs replacing. Does anyone have any examples or advise about writing a good non offensive 401 page? ...

Setting the HTTP response status code from ASMX Web Service

Hello, I know with ASP.NET there's a global handler Application_EndRequest handler where I could change the Context.Response.StatusCode, and set it to 200 which is my desire. Now with asmx Web Services, I'm not really sure where I'd put this logic in. I know I'm definitely not interested in writing an ISAPI Filter, and I'm not really...

Proper use of HTTP status codes in a "validation" server

Among the data my application sends to a third-party SOA server are complex XMLs. The server owner does provide the XML schemas (.xsd) and, since the server rejects invalid XMLs with a meaningless message, I need to validate them locally before sending. I could use a stand-alone XML schema validator but they are slow, mainly because of ...

Getting correct Response.StatusCode from Application_OnError (ASP.NET MVC)

I'm trying to create some basic logging for unhandled exceptions in my ASP.NET MVC application, but as I'm using IIS6 all requests come through .NET. Now while I agree that missing images are an important thing to flag, they aren't show-stoppers and so I'd like to set the event priority to high for 404s unless they are images (which wil...

How return 304 status with FileResult in ASP.NET MVC RC1

As you may know we have got a new ActionResult called FileResult in RC1 version of ASP.NET MVC. Using that, your action methods can return image to browser dynamically. Something like this: public ActionResult DisplayPhoto(int id) { Photo photo = GetPhotoFromDatabase(id); return File(photo.Content, photo.ContentType); } In the ...

Eradicating 401 "Unauthorised" responses followed by 200 "Ok" responses

I’ve got a situation with a large internal corporate web based application running ASP.NET 3.5 on IIS6 generating 401 “Unauthorised” responses followed by 200 “Ok” responses (as profiled by Fiddler). I’m aware of why this happening (integrated auth forcing the browser to resend credentials) but I’m looking for some thoughts on how to min...

How can I reliably detect if Flash was the originator of a request to a service?

I need to be able to detect if flash was the originator of a request to an ASP.NET service. The reason being that Flash is unable to process SOAP messages when the response status code is something other than 200. However, I allow exception to bubble up through our SOAP web services and as a result the status code for a SOAP server fault...

Getting IIS Status Code From an Exception

Greetings! I'm handling exceptions with an HttpModule in a manner such as this: int errorCode = 500; HttpApplication httpApp = (HttpApplication)sender; try { if (httpApp.Server != null) { Exception ex; for (ex = httpApp.Server.GetLastError(); ex != null; ex = ex.InnerException) { try ...

Grabbing status code without using a server-side language (javascript, perhaps?)

I've created a service that helps with error pages in web apps via an snippet of code that is copy/pasted in to the error page templates (a la Google Analytics). The status code is set to a hidden input within the installation code. The problem is that I don't want the installation code to be dependent on a server-side language (e.g. PHP...

How do I pass error information through an HTTP Request in Flex 3?

My Flex3 application must display meaningful application-level error messages from the server. This article article says that Flash has severe limitations on receiving error info, whether as status codes, response body, or response headers as described. I can use any of these from my servlet. But apparently none are accessible! But the...

Flash Contact Form; Trouble Returning Server Response

I have a contact form that connects to my site's back-end, the form submits just fine but I get no server response. It's always 'undefined'. I'm worried it may be because of this, but I was hoping maybe one of you smarter folks could help me find either a workaround or if it isn't because of that (note: most likely), then maybe you could...

Rails HTTP Status always returns 200 in development

I'm using Mongrel in development mode for my rails app. I noticed that regardless of the what the actual HTTP status should be, it is being returned as 200 to the browser. In production mode, the status is correct. For example, when the record it is not found, the app displays the correct (not found) view, but the status sent to the br...

Difference between status codes and error codes

folks, How can I differentiate between error codes and status codes in case of Servlet response? Is it right to say that there is some status codes in HttpServletResponse class which show errors. Or I've to use more definite way to differentiate between them? ...

What HTTP status code is most search-engine-friendly during a planned outage?

If you have to take a site down for some type of unavoidable maintenance task (and it's not a big enough site that you have a backup server), what HTTP status code should you have your server return to minimize the possibility that search engines will think the site is gone? I found this list of status codes from W3C, of which the follo...

Using HTTP status codes in web applications

I'm currently building a web application (utilizing Zend Framework) and have gotten some of the basic HTTP status codes down, such as: 404 on missing controller/action 500 on server exception 3xx returned by Apache At the moment I have just implemented some basic ACL checking that the user is authorized to access a certain resource. ...

Why my httpwebrequest post to myhandler.ashx is rejected with status code 401

I've already written an HTTPHandler that gets POSTed from a ColdFusion page and it works successfully; now, I am trying to write a web application in ASP.NET so I can post a form to the .ashx handler from an .aspx page. Application Trace (trace.axd) shows the following as my last 3 entries: 2 8/14/2009 1:53:56 PM /Default.aspx 2...

When I hardcode an ASP.NET HTTP-StatusCode to 401, I keep getting bounced to the login page?

Hi folks, I've got an API setup. When the user provides an invalid/missing API key, I'm trying to set the Response.StatusCode to 401, something keeps bouncing me to my login page. It's an API ... so I don't want that. I wish to send them the json error message with the code being 401. url for this sample api is : /api/search/foo?apike...

HTTP status code for bad data

What HTTP status code should I return when a client posts bad data (e.g. a string when integer was expected)? I've been using 400 Bad Request, but as I read over the HTTP docs that seems more applicable to HTTP protocol errors. I'd like to use a status code so that Flash and AJAX clients can distinguish between success, bad data, and s...

Compatibility of HTTP status.

I'm currently implementing a RESTful API (nothing serious, just for a blog engine i'm developping for fun) and i've some questions about HTTP status compatibility. To create a new blog post i have to do a POST request, if every thing goes fine, the post is created and then returned in the format corresponding to the request. I read on ...

Python CGI returning an http status code, such as 403?

Hi, How can my python cgi return a specific http status code, such as 403 or 418? I tried the obvious (print "Status:403 Forbidden") but it doesn't work. ...