Previous Next

Thread: Problem adding additional hostheader

Last post 06-14-2008 3:11 AM by JaroDunajsky. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 06-06-2008, 9:44 AM

    • usmanjamil
    • Top 500 Contributor
    • Joined on 10-31-2007, 1:14 PM
    • Islamabad
    • Posts 9

    Problem adding additional hostheader

    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;
    }

  • 06-14-2008, 3:11 AM In reply to

    Re: Problem adding additional hostheader

    Modifying configuration of your site from by application internal to the site doesn't seem like a good idea to me. Are you sure that is something you need to do?

    But to answer your question: Your problem is caused by processing config change notification.

    Jaroslav Dunajsky (MSFT, IIS)
Page 1 of 1 (2 items)
Page view counter