Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7416255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:27:30+00:00 2026-05-29T07:27:30+00:00

I need to programatically add an IIS 7.x site and I got stuck when

  • 0

I need to programatically add an IIS 7.x site and I got stuck when this should be created with a HTTPS/SSL binding by default, usig SiteCollection.Add(string, string, string, byte[]) overload.

Giving https:*:80:test.localhost https:*:443:test.localhost as bindingInformation throws an ArgumentException with this message: The specified HTTPS binding is invalid.

What’s wrong in this binding information?

Thank you.

EDIT: I’m using Microsoft.Web.Administration assembly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:27:31+00:00Added an answer on May 29, 2026 at 7:27 am

    Here is what I did to create https site and it worked. I skip some parts of code here, of course.

    using Microsoft.Web.Administration
    ...
    using(var manager = new ServerManager())
    {
        // variables are set in advance...
        var site = manager.Sites.Add(siteName, siteFolder, siteConfig.Port);
    
        var store = new X509Store(StoreName.AuthRoot, StoreLocation.LocalMachine);
        store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);
    
        // certHash is my certificate's hash, byte[]
        var binding = site.Bindings.Add("*:443:", certHash, store.Name);
        binding.Protocol = "https";
    
        store.Close();
    
        site.ApplicationDefaults.EnabledProtocols = "http,https";
    
        manager.CommitChanges();
    }
    

    UPD: the certificate is created from a pfx file the following way:

    // get certificate from the file
    string pfx = Directory.GetFiles(folder, "*.pfx", SearchOption.AllDirectories).FirstOrDefault();
    var store = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
    store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);
    
    var certificate = new X509Certificate2(pfx, certPassword, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
    store.Add(certificate);
    store.Close();
    certHash = certificate.GetCertHash();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a UITableView which has been created programatically. I'm now trying to add
So I'm trying to add UIImageViews programatically (in this case I don't have the
I need to create a UIButton programatically and then put it on a created
I am programatically adding a UINavigationBar to a UIView, and now need to add
I'm creating a layout programatically and need to add a TextView. Only problem is,
I am having listview in linear layout, where I need to programatically add button.
I need to be able to programatically add a google account in android for
We need to programatically burn files to CD in a C\C++ Windows XP/Vista application
I need to programatically determine whether .NET 3.5 is installed. I thought it would
I need to programatically append to a multi-page TIFF or PDF a new image.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.