Jitender Mandhaniya wrote:I want to show error message if the browser is not able to display the file.
As Paul already said, there really is no way for the server to know what the rendering capabilities are of the browser. The browser knows, and there is a mechanism for the browser to inform the server, but typically browsers tell the server they support everything.
The HTTP
Accept header presented by the browser
should detail the types of content it will accept (and be able to render), and
if the information provided by the browser was actually accurate, the server could use this information to decide what type of content to return. But unfortunately, browsers usually include a wildcard of
*/*, indicating that they will accept all content types, so the server really cannot make an informed decision.
Here an example of a request from my Chrome browser:
You can see that the
Accept header includes
*/*
Specialized clients, like web service clients are usually a lot better at really indicating what they can use: