如何對SharePoint裡OOB的JavaScript檔案進行Debug 之一

來源:互聯網
上載者:User

使用一篇文章的做法,開始了對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。先不多想了,照著做先。

 

於是,筆者按照該文章的說法,直接修改web.config如下:

儲存後,開啟任意網頁都報錯。修改web.config, 關掉其CustomError選項, 得到具體錯誤資訊如下:

錯誤資訊:

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專家的說法經過了筆者測試。

有圖有真相

 

花費了一個下午的時間,結果證明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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.