Hi
I have a website say mysite.com. Its running .Net code and from within this .Net code i'm adding a hostheader on this site itself. Below is the code i'm using to add hostheader. What happens is that the hostheader gets added successfully, but the sessions of my .Net code ends like the site has restarted or something. Is this behaviour normal?? If yes, how can i add hostheader onto a site from the code running on that site itself.
try
{
Site website = server.Sites[m_szSiteName];
if (website != null)
{
string szBinding = m_szIPAddress + ":" + m_uiPort.ToString() + ":" + m_szHostHeader;
bool bBindingExists = false;
foreach (Binding binding in website.Bindings)
{
string szBindingInfo = binding.BindingInformation.ToLower();
if (szBindingInfo.Equals(szBinding.ToLower()))
{
bBindingExists = true;
break;
}
}
if (!bBindingExists)
{
website.Bindings.Add(szBinding, "http");
server.CommitChanges();
sRet = 1;
}
}
else
{
string szError = "website does not exists";
}
website = null;
}
catch (Exception ex)
{
sRet = 0;
m_szErrorReason = ex.Message;
}