简体   繁体   中英

On which port my web application is running asp.net C#

有没有办法找到我的Web应用程序使用C#代码运行的端口,因为我喜欢用整数变量写它?

You can get it this way, MSDN , If you could not see port in url it means the port is 80.

int port =  Request.Url.Port;

or you can get from url

Uri uri = new Uri("http://www.mywebsite.com:80/pages/page1.aspx");
int port  = uri.Port;

If you running from Visual Studio then every time it will pick up a new port number, once you have deployed your application then it will pick up the port given for your website.

The default port is 80 .

如果使用Visual Studio Development Server或在IIS设置中选择端口,则可以在项目设置中选择端口。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM