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 7487999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:42:41+00:00 2026-05-29T14:42:41+00:00

I am currently developing an ASP.NET MVC 3 site using Visual Studio 2010 with

  • 0

I am currently developing an ASP.NET MVC 3 site using Visual Studio 2010 with SSL enabled for debugging on my local machine via IIS Express. A port is assigned for http and https in the applicationhost.config file for my site.

For the sake of example, let’s say my http port is 3333, and my https port is 6666.

Is there a way to access these port numbers that are configured in IIS Express programatically in my ASP.NET code?

I can access the port number I am currently using, ie. if I am hitting a page at http://localhost:3333/somepage, then I can get at the 3333, but I want to be able to get the 6666 from the web server configuration.

  • 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-29T14:42:42+00:00Added an answer on May 29, 2026 at 2:42 pm

    You can get the ports using the Binding class of Microsoft.Web.Administration. Below is an example.

    using (ServerManager sm = new ServerManager())
    {
        var bindings = sm.Sites[HostingEnvironment.ApplicationHost.GetSiteName()].Bindings;
        foreach (Binding b in bindings)
        {
            if (b.IsIPPortHostBinding)
            {
                if (b.Protocol.Equals("http"))
                    Debug.WriteLine("HTTP port is " +  b.EndPoint.Port);
                else if (b.Protocol.Equals("https"))
                    Debug.WriteLine("HTTPS port is " + b.EndPoint.Port);
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently developing an MVC application in ASP.net. I am using AJAX.ActionLink to
Currently in the early stages of developing a very large project using ASP.Net MVC.
I am currently developing an events calendar application using ASP.NET MVC and SQL Server
I'm currently developing an image viewer using asp.net MVC. The image viewer itself works
I'm currently developing a website in ASP .NET MVC and I require functionality for
We are developing an ASP.NET MVC Application that currently uses it's own database ApplicationData
I am developing an application using ASP.NET MVC 1 and VS2008. When I deploy
I'm currently developing an ASP.NET MVC application with a ton of PK-FK relationships in
We are currently developing a web application in ASP.NET MVC which would really benefit
I'm currently developing an ASP.NET Human Resources System. I'm using a layered architecture with

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.