自从我联系支持部门以来已经有几个星期了,但在与配置和设置的几次来回过程中,他们最终要求我提供对象引用错误的堆栈跟踪。
这导致我与我的一位同事(最近一直在研究 Tridion 的日志记录)一起调整日志记录配置,以便查看堆栈跟踪输出。不幸的是,在向支持报告问题后,我重置了我正在处理的环境(因为我也一直在努力升级到 Tridion 2011),当他们提出这个请求时,SiteEdit 没有按照它的配置记录到应用程序事件日志中(我认为这可能是权限问题)。
为了获得堆栈跟踪,我的同事将 \Tridion\SiteEdit 2009\tridion.logging.config 更改为登录到文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=349a39f202fa9b53" />
</configSections>
<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="false">
<listeners>
<add name="Log File" fileName="C:\Tridion\log\SiteEdit.log" formatter="Tridion Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=349a39f202fa9b53" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=349a39f202fa9b53" />
</listeners>
<formatters>
<add template="{timestamp} <{win32ThreadId}> {message}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=349a39f202fa9b53" name="Trace Text Formatter" />
<add template="{message}

Component: {keyvalue(component)}
Errorcode: {keyvalue(errorcode)}
User: {keyvalue(username)}

{keyvalue(stacktrace)}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=349a39f202fa9b53" name="Tridion Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General" />
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events">
<listeners>
<add name="Log File" />
</listeners>
</allEvents>
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings" />
</specialSources>
</loggingConfiguration>
</configuration>
一旦将日志记录配置为写入文件,我们就可以看到异常的堆栈跟踪:
读取传入请求时出错。
你调用的对象是空的。
组件:SiteEdit.Proxy
错误代码:0
用户:NT AUTHORITY\IUSR
StackTrace 信息详细信息:
在 Tridion.Web.UI.SiteEdit.Proxy 的 Tridion.Web.UI.SiteEdit.Proxy.Helper.CopyRequestCookies(HttpRequest request, CookieContainer cookieContainer)
。
Tridion.Web.UI.SiteEdit.Proxy.Request.RequestFactory.CreateRequest(HttpRequest request)的Request.RequestFactory.CreateRequest(HttpRequest 请求)
Tridion.Web.UI.SiteEdit.Proxy.RedirectModule.context_BeginRequest(Object sender, EventArgs e)
由于对象引用错误出现在名为“CopyRequestCookies”的方法中,我们决定查看我们的 cookie(这是有道理的,因为关闭并重新打开浏览器导致 SiteEdit 再次工作,但仅针对单个请求)。
果然,我们有一个奇怪的 cookie,它被用来简单地验证用户是否打开了 cookie。javascript代码(我认为我的开发人员从网上某处获得)是:
document.cookie = 'CookieTest';
if (document.cookie == "") {
$("form").append('<div class="master-error"><p>Cookies are not enabled</p></div>');
}
注意 cookie 没有值(典型的 JS 是document.cookie = 'name=value';
)。我们认为在代理逻辑中,它将为代理站点提交的 cookie 传递到暂存站点,有一些代码没有预期 cookie 没有价值(在 Fiddler 中,您可以看到 cookie 只是传递作为“CookieTest;”),但没有进行防御性编码来处理这种情况。
通过更改我们的代码以将值应用于 cookie document.cookie = 'CookieTest=true'
,SiteEdit 代理可以正常工作。