Using the HTML5 File API to upload files, I am currently using some hardcoded checking of the browsers that support them, depending on the user agent string:
internal bool IsHtml5FileUploadCapable
{
get
{
var browser = Request.Browser;
var n = browser.Browser.ToLowerInvariant();
var major = browser.MajorVersion;
var minor = browser.MinorVersion;
return
n.Contains(@"chrome") && major >= 6 ||
n.Contains(@"ie") && major >= 10 ||
n.Contains(@"firefox") && (major >= 3 && minor > 6 || major >= 4) ||
n.Contains(@"opera") && (major >= 11 && minor >= 5 || major >= 12) ||
n.Contains(@"safari") && major >= 4;
}
}
What I love to use would be the built-in "App_Browsers" functionality in conjunction with the HttpBrowserCapabilities
class.
My question:
Is it possible to deduce the ability of a browser to support the HTML5 File API directly from the browser capabilities?
It may not be exactly what you are asking about, but having a look on the javascript library, called Modernizr ( http://www.modernizr.com/docs/ ), might be useful for your usecase. It's, of course, client-side check and not server-side one.
It is capable of detecting quite a lot of HTML5 features.
来源:https://stackoverflow.com/questions/7772416/is-there-a-chance-to-use-app-browsers-to-detect-support-of-the-html5-file-api