设为首页 收藏本站
查看: 1284|回复: 0

[经验分享] 如何对SharePoint里OOB的JavaScript文件进行Debug 之一

[复制链接]

尚未签到

发表于 2015-9-27 10:19:54 | 显示全部楼层 |阅读模式
  使用一篇文章的做法,开始了对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=&quot;false&quot; /> 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。先不多想了,照着做先。
DSC0000.png
  
  于是,笔者按照该文章的说法,直接修改web.config如下:
DSC0001.png
  保存后,打开任意网页都报错。修改web.config, 关掉其CustomError选项, 得到具体错误信息如下:
DSC0002.png
  错误信息:
  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=&quot;deployment&quot; type=&quot;System.Web.Configuration.DeploymentSection, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot; allowDefinition=&quot;MachineOnly&quot;/>
  笔者直接删掉了allowDefinition=&quot;MachineOnly&quot;,问题依旧。继续研究,发现在对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=&quot;true&quot;,还是不行。
  还原web.config, 单独修改machine.config,结果debugger中加载的还是普通的js,而不是debug版的js文件。
  
  咨询了IIS的专家,得到答复说这个选项是不能在web.config中定义的。而且我的测试也证明了实在是无法解决这项冲突。
  IIS专家说,你要load debug版的javascript,其实只要<compilation batch=&quot;false&quot; debug=&quot;true&quot;>里的debug设为true即可。
  IIS专家的说法经过了笔者测试。
  有图有真相
DSC0003.png
  
  花费了一个下午的时间,结果证明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

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-119374-1-1.html 上篇帖子: 自定义Sharepoint网站的路径 下篇帖子: 如何手动删除 SharePoint Portal Server
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表