Is there a chance to use App_Browsers to detect support of the HTML5 File API?

好久不见. 提交于 2019-12-22 13:04:42

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!