Get ASP.NET development server port number

2020-04-11 13:17发布

问题:

I need to get asp.net development server port number in C# method. can you help me?

回答1:

You can get it from Request:

Request.Url.Port

And this is not strictly port of Development web server, this is a port of currently used web server.