Force ASP.NET to generate JavaScript for all User Agents

后端 未结 1 1522
独厮守ぢ
独厮守ぢ 2020-12-11 04:00

I noticed recently in my ASP.NET web application that if I set my User Agent to an empty string (using a FireFox plug-in to spoof the user agent), then ASP.NET will not gene

相关标签:
1条回答
  • 2020-12-11 04:20

    If you set empty to the User Agent, or if you use an unknown User Agent string, then asp.net reads the Default.browser file from Browsers directories and there you can define how to you like to act on this cases.

    The lines that you need to change and on this cases use javascript is that ones:

            <capability name="jscriptversion"       value="5.6" />
            <capability name="javascript"           value="true" />
            <capability name="javascriptversion"    value="1.5" />
    

    on the default, the javascript line if false. I like to comment here that I am not so sure if you really need to change it, if some one spoof the user agent, let it do it. If he likes your site and need to use it, then is better let you know how to handle the browser that he use. From the other hand you must take care if this is possible, your site to work even with out javascript, at least for most of the actions you do.

    Is better to avoid link buttons (that use the _doPostBack) and use post back buttons for example. I know that GridView and other use also the _doPostBack for paging... ok with that, but is better one good site to been able to work even with out javascript.

    Some similar question:
    __doPostBack is undefined on DotNetNuke website for IE 10

    and this blog: Bug and Fix: ASP.NET fails to detect IE10 causing _doPostBack is undefined JavaScript error or maintain FF5 scrollbar position

    0 讨论(0)
提交回复
热议问题