use
spsite.exists();
http://msdn.microsoft.com/en-us/library/ms428778(v=office.14).aspx
//if site doesnt exist
if (!SPSite.Exists("http://google.com"))
{
//make site
}
if it doesnt like the above you might need to have the string as an actual uri like so:
//if site doesnt exist
Uri url = new Uri("http://google.com");
if (!SPSite.Exists(url))
{
//make site
}
else
{
this.Controls.Add(new LiteralControl("<div style='color:Red'><p><strong>Sorry site already exists!</strong></p></div>"));
}
EDIT
just to clarify:
Uri url = new Uri("http://google.com");
if (!SPSite.Exists(url))
{
Console.Out.Write("site doesnt exists, create me");
Console.Out.WriteLine();
Console.Read();
}
else
{
Console.Out.Write("site exists sorry you cant!");
Console.Out.WriteLine();
Console.Read();
}
thats what i used to test and works just fine in a console app! I need to see some code to see where your going wrong, how your calling this code and whats going in within the if function! how your displaying the message!