0

我们已经在crossdomain.xmlSharepoint 2010 实例的根目录中部署了一个文件,以定义 flash 跨域策略。在 SP2007 中,这按预期工作,但在 SP2010 中,文件被阻止。

crossdomain.xml如果我们将文件重命名为它所提供的任何其他名称。一旦我们将其命名为我们想要的名称,它就会引发 404 错误。

任何想法如何解决这个问题?我猜现在必须有一种方法可以通过 SharePoint 本身来控制这个文件?

除了将 crossdomain.xml 文件复制到 IIS 的根目录之外,我一直在寻找答案。

4

1 回答 1

3

我发现了这不起作用的原因。事实证明,在 SharePoint 2010 中,路径crossdomain.xml并被clientaccesspolicy排除在虚拟路径提供程序之外,因此永远不会从 SharePoint 内容数据库中提供服务。

代码隐藏在 Sharepoint 中SPRequestModule(见下文)。唯一明智的解决方案是将crossdomain.xml文件部署到每个 Web 服务器上的 IIS 根目录,这并不理想。

[SharePointPermission(SecurityAction.Demand, ObjectModel=true)]
void IHttpModule.Init(HttpApplication app)
{
    if (app is SPHttpApplication)
    {
        if (!_virtualPathProviderInitialized)
        {
            lock (_virtualServerDataInitializedSyncObject)
            {
                if (!_virtualPathProviderInitialized)
                {
                    Dictionary<string, ExclusionAttributes> dictionary = new Dictionary<string, ExclusionAttributes>(StringComparer.OrdinalIgnoreCase);
                    dictionary["/app_themes"] = ExclusionAttributes.Folder;
                    dictionary["/app_browsers"] = ExclusionAttributes.Folder;
                    dictionary["/defaultwsdlhelpgenerator.aspx"] = ExclusionAttributes.File;
                    dictionary["/clientaccesspolicy.xml"] = ExclusionAttributes.File;
                    dictionary["/crossdomain.xml"] = ExclusionAttributes.File;
                    VirtualPathProvider virtualPathProvider = HostingEnvironment.VirtualPathProvider;
                    if ((virtualPathProvider != null) && virtualPathProvider.DirectoryExists("/"))
                    {
                        VirtualDirectory directory = virtualPathProvider.GetDirectory("/");
                        if (directory != null)
                        {
                            IEnumerable children = directory.Children;
                            if (children != null)
                            {
                                foreach (VirtualFileBase base2 in children)
                                {
                                    string str = base2.VirtualPath.TrimEnd(new char[] { '/' });
                                    ExclusionAttributes attributes = 0;
                                    if (base2.IsDirectory)
                                    {
                                        attributes |= ExclusionAttributes.Folder;
                                    }
                                    else
                                    {
                                        attributes |= ExclusionAttributes.File;
                                    }
                                    dictionary[str] = attributes;
                                }
                            }
                        }
                    }
                    _excludedFileList = dictionary;
                    SPVirtualPathProvider provider2 = new SPVirtualPathProvider();
                    HostingEnvironment.RegisterVirtualPathProvider(provider2);
                    _virtualPathProviderInitialized = true;
                }
                SPTemplateFileSystemWatcher.Local.Initialize();
                SPPerformanceCounterAgent current = SPPerformanceCounterAgent.Current;
            }
        }
        app.BeginRequest += new EventHandler(this.BeginRequestHandler);
        app.PostAuthenticateRequest += new EventHandler(this.PostAuthenticateRequestHandler);
        app.PostAuthorizeRequest += new EventHandler(this.PostAuthorizeRequestHandler);
        app.PostResolveRequestCache += new EventHandler(this.PostResolveRequestCacheHandler);
        app.PostAcquireRequestState += new EventHandler(this.PostAcquireRequestStateHandler);
        app.PreRequestHandlerExecute += new EventHandler(this.PreRequestExecuteAppHandler);
        app.PostRequestHandlerExecute += new EventHandler(this.PostRequestExecuteHandler);
        app.ReleaseRequestState += new EventHandler(this.ReleaseRequestStateHandler);
        app.Error += new EventHandler(this.ErrorAppHandler);
        app.PostLogRequest += new EventHandler(this.PostLogRequestHandler);
        app.EndRequest += new EventHandler(this.EndRequestHandler);
    }
}
于 2011-09-19T22:01:49.313 回答