【问题标题】:SharePoint 2010 CrossDomain.xml fileSharePoint 2010 跨域.xml 文件
【发布时间】:2011-09-20 06:01:49
【问题描述】:

我们已将crossdomain.xml 文件部署到 Sharepoint 2010 实例的根目录中,以定义 Flash 跨域策略。在 SP2007 中,这按预期工作,但在 SP2010 中,文件 name 被阻止。

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

任何想法如何解决这个问题?我猜现在肯定有办法通过 SharePoint 本身来控制这个文件?

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

【问题讨论】:

  • 您能以对他人有所帮助的方式回答您自己的问题吗?如果你这样做,你可以选择你的作为正确答案。这可能看起来很奇怪,但它是处理此类情况的首选方式。

标签: sharepoint-2010 cross-domain-policy


【解决方案1】:

我发现了这不起作用的原因。事实证明,在 SharePoint 2010 中,路径 crossdomain.xmlclientaccesspolicy 被排除在虚拟路径提供程序之外,因此永远不会从 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);
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-05
    • 2014-09-04
    • 2010-10-30
    • 2013-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-10
    相关资源
    最近更新 更多