English 中文(简体)
如何在试图创建新网站时确定“SongPoint”例外
原标题:How to identify the SharePoint exception when trying to create a new site

Ok,

这似乎令人困惑,但我表示,我会问,因为这里有许多专门知识可供利用,我或许会从答复中学习一个好的轨道。

我设有一个服务中心小组,负责创建网站。 如果网站的创建失败,我想删除这个网站。 EXCEPT, 如果是例外,因为在URL已经存在另一个地点。

目前,我会收到以下文件,很容易检查其中的案文,但希望采取更加坚实的办法。 (例如,寻找一种例外的身份证或这方面的东西。)

Another site already exists at http://server:80/sites/xxxxxxxx. Delete this site before attempting to create a new site with the same URL, choose a new URL, or create a new inclusion at the path you originally specified.

最佳回答

为什么不请你检查一下,看看是否首先在试图建立这个网站之前就存在?

问题回答

正如TrovB30所说,在试图创造之前检查是否存在,可能是这样做的最佳方式。

我假定你指的是SPSiteCollection物或SPWebApplication物? 在这种情况下,我或许会看一下是否存在。 这可能看起来很麻烦,但可能比审判渔获程序更有效率:

private bool SiteExists(SPWebApplication webApp, string siteUrl)
    {            
        var sites = webApp.Sites;
        //Add slash to enable comparison
        siteUrl = "/" + siteUrl;
        foreach (SPSite site in sites)
        {
            if (site.ServerRelativeUrl.Equals(siteUrl) == true)
            {
                return true;
            }
        }
        return false;
    }




相关问题
handling exceptions IN Action Filters

Is there a better way to handle exceptions that occur inside an Action Filter itself in ASP .NET MVC? There re 2 ways I can think of at the moment. Using a try catch and setting the HTTP Status ...

既可捕获,又可举出例外。

我有一种办法,可以进入亚洲开发银行,因此,我国的亚行在多瑙河航道中的所有 st子都位于一个试捕区。 它正在追捕Kexception

Cross compiler exception handling - Can it be done safely?

I am doing some maintenance on a C++ windows dll library that is required to work with different VC++ compilers (as I don’t want to address different mangling schemes). I have already eliminated any ...

File Handling Issue

I am developing a tool in c#, at one instance I start writing into a xml file continuously using my tool,when i suddenly restart my machine the particular xml file gets corrupted, what is the reason ...

Watch a memory location/install data breakpoint from code?

We have a memory overwrite problem. At some point, during the course of our program, a memory location is being overwritten and causing our program to crash. the problem happens only in release mode. ...

Unit Test for Exceptions Message

Is there a simple (Attribute-driven) way to have the following test fail on the message of the exception. [TestMethod()] [ExpectedException(typeof(ArgumentException))] public void ExceptionTestTest() ...

热门标签