zoukankan      html  css  js  c++  java
  • 如何对SharePoint里OOB的JavaScript文件进行Debug 之一

    使用一篇文章的做法,开始了对SharePoint JavaScript的debugging,发现VS2010中打开的JavaScript都挤在一起,非常难以阅读和debug。

    笔者记得14 hive\layouts文件夹下有debug版的JavaScript的。却不知道如何使用它们。

    经过研究,发现MSDN上文章的对这个问题进行了描述,摘抄如下。

    SharePoint Foundation also installs unminified, debug versions of the .js files in the same directory, for example, SP.debug.js, SP.Core.debug.js, SP.Ribbon.debug.js, and SP.Runtime.debug.js, and you can specify whether the debug versions are used. Default master pages in SharePoint Foundation insert a ScriptManager control in Web pages, and the ScriptMode property of this control is set to Auto by default.

    You can override this default setting and use the debug .js files by adding <deployment retail="false" /> to the system.web section of the web.config file, which is located in the %inetpub%\wwwroot\wss\VirtualDirectories\80 directory.

    注意MSDN描述retail值为true的影响如下:

    When retail is set to true, ASP.NET disables certain configuration settings such as trace output, custom errors, and debug capabilities.

    而且,默认值本来就是false。先不多想了,照着做先。

    image

    于是,笔者按照该文章的说法,直接修改web.config如下:

    image

    保存后,打开任意网页都报错。修改web.config, 关掉其CustomError选项, 得到具体错误信息如下:

    image

    错误信息:

    It is an error to use a section registered as allowDefinition='MachineOnly' beyond machine.config.

    再搜索,发现这篇文章对这个错误信息有如下的解释:

    This message is displayed when a section definition specifies that it may only be provided in the Machine.Config file. The Identity section is not normally set this way, but it is possible for your ISP to change it in Machine.Config is they don't want users to be able to override the sections. Normally the admin should use a location tag with allow override=false to accomplish this, but the results are pretty much the same, the web.config may not contain the section in question. If you control the server you should check the configuration section definitions to see if the MachineOnly attribute is set on the section you are having problems. Removing the section that is causing the error will solve the problem, although you will not be able to change the attributes of that section.

    这个选项看来是只在machine.config中提供的。目的是为了防止用户修改这个选项。

    在路径C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG下寻找到machine.config, 发现有如下的条目:

    <section name="deployment" type="System.Web.Configuration.DeploymentSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" allowDefinition="MachineOnly"/>

    笔者直接删掉了allowDefinition="MachineOnly",问题依旧。继续研究,发现在对IIS7.0的配置体系介绍的文章中,对MachineOnly选项介绍如下:

    MachineOnly The section can be set only in ApplicationHost.config or Machine.config. Because this is the default setting, a section that doesn’t have an allowDefinition attribute uses this setting automatically.

    笔者尝试修改该选项为MachineToApplication,AppHostOnly均告失败。笔者还添加了allowoverride="true",还是不行。

    还原web.config, 单独修改machine.config,结果debugger中加载的还是普通的js,而不是debug版的js文件。

    咨询了IIS的专家,得到答复说这个选项是不能在web.config中定义的。而且我的测试也证明了实在是无法解决这项冲突。

    IIS专家说,你要load debug版的javascript,其实只要<compilation batch="false" debug="true">里的debug设为true即可。

    IIS专家的说法经过了笔者测试。

    有图有真相

    image

    花费了一个下午的时间,结果证明Client Object Model Distribution and Deployment 这篇文章完全在胡说八道。

    而我的debug任务才只开了个头。

    坑爹呀~~

    链接

    =====================

    如何对SharePoint里OOB的JavaScript文件进行Debug 之二

    参考资料

    =====================

    Client Object Model Distribution and Deployment

    http://msdn.microsoft.com/en-us/library/ie/ee539757.aspx

    Scripting Debugging in Internet Explorer

    http://blogs.msdn.com/b/ie/archive/2004/10/26/247912.aspx

    deployment Element (ASP.NET Settings Schema)

    http://msdn.microsoft.com/en-us/library/ms228298.aspx

    Introducing IIS 7.0 Configuration Architecture

    http://technet.microsoft.com/en-us/library/cc268239.aspx

    ScriptManager.ScriptMode Property

    http://msdn.microsoft.com/EN-US/library/system.web.ui.scriptmanager.scriptmode

  • 相关阅读:
    [页面布局方式]
    padding and margin
    【浏览器中的页面】
    【浏览器的页面循环系统】
    Activity启动模式详解(二)--->singleTask
    finish、onDestory、System.exit的区别
    Androidndk开发打包时我们应该如何注意平台的兼容(x86,arm,arm-v7a)
    关于WifiManager的一些看法
    高效的找出两个List中的不同元素
    关于Activity的生命周期
  • 原文地址:https://www.cnblogs.com/awpatp/p/2328049.html
Copyright © 2011-2022 走看看