SharePoint 2010 CrossDomain.xml 文件

发布于 2024-12-04 17:37:29 字数 344 浏览 1 评论 0原文

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

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

有什么想法可以解决这个问题吗?我猜想现在一定有一种方法可以通过 SharePoint 本身来控制这个文件?

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

We have deployed a crossdomain.xml file into the root of Sharepoint 2010 instance in order to define the flash cross domain policy. In SP2007 this worked as expected, but it SP2010 the file name is blocked.

If we rename the file anything other than crossdomain.xml it's served. As soon as we name it what we want, it throws a 404 error.

Any ideas how to work around this? I'm guessing there must now be a way to control this file through SharePoint itself?

I've looking for an answer other than to copy the crossdomain.xml file into the root of IIS.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜夜流光相皎洁 2024-12-11 17:37:29

我发现了这行不通的原因。事实证明,在 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);
    }
}

I discovered the reason this doesn't work. It turns out in SharePoint 2010 the path crossdomain.xml and clientaccesspolicy are excluded from the virtual path provider, and therefore will never be served from the SharePoint content database.

The code is tucked away in the Sharepoint SPRequestModule (see below). The only sensible solution is to deploy the crossdomain.xml file to the root of IIS on each of the web servers, which is less than ideal.

[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);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文