【Azure Developer】Visual Studio 2019中如何修改.Net Core应用通过IIS Express Host的应用端口(SSL/非SSL)

简介: 【Azure Developer】Visual Studio 2019中如何修改.Net Core应用通过IIS Express Host的应用端口(SSL/非SSL)

问题描述

在VS 2019调试 .Net Core Web应用的时,使用IIS Express Host,默认情况下会自动生成HTTP, HTTPS的端口,在VS 2019的项目属性->Debug中查看设置如下:

而此处的SSL(HTTPS)端口无法从Debug页修改。这里是否有其他办法呢?

 

解决办法

端口由项目文件LaunchSettings.json配置,当不知道项目中是何处进行控制SSL的值时,可以通过Ctrl + F进行全解决方案的搜索。找出那些文件中包含了44303的关键字,如下:

 

最终查找到Porject下的Properties文件中, LaunchSettings.json中包含了iisExpress http和https的端口设置(高亮部分)。在对sslPort进行修改后,即可得到端口修改的办法。

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:52481",
      "sslPort": 44303
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "WebApplication1": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "dotnetRunMessages": "true",
      "applicationUrl": "https://localhost:5001;http://localhost:5000"
    }
  }
}

修改为44322后的测试情况,可以通过新的端口访问应用

 

PS: 注意,并不是任何端口都可以成功,如这里设置55555,就出现无法访问的错误。

 

这是因为IIS Express SSL 的保留端口为44300 ~ 44399.   文档:https://docs.microsoft.com/en-us/iis/extensions/using-iis-express/running-iis-express-without-administrative-privileges

Using SSL

Configuring access over the secure sockets layer (SSL) requires administrative privileges on IIS Express, just like it does on IIS. However, the IIS Express setup program performs the following tasks that enable standard users to use SSL with IIS Express:

  • It automatically creates and installs a self-signed SSL server certificate in the local machine store.
  • It configures HTTP.SYS to reserve ports 44300 through 44399 for SSL. Incoming SSL requests that use localhost and one of the ports in the specified range are automatically associated with the self-signed certificate.

(HTTP.SYS is an operating system component that handles SSL for IIS and IIS Express. The setup program is able to configure HTTP.SYS because setup runs under elevated privileges.)

相关文章
|
7月前
|
存储 JSON 开发工具
Visual Studio编程效率提升技巧集(提高.NET编程效率)
Visual Studio编程效率提升技巧集(提高.NET编程效率)
163 0
Visual Studio编程效率提升技巧集(提高.NET编程效率)
|
安全 搜索推荐 网络安全
百度搜索:蓝易云【IIS服务器上安装SSL证书?】
通过按照上述步骤正确安装SSL证书并配置IIS服务器,您的网站将获得HTTPS连接,提供更安全的访问体验。这有助于提高您的网站在搜索引擎结果中的排名,并确保用户数据的保护。请记住,在SEO优化方面,确保网站内容的优质和关键词的优化也是至关重要的。
619 0
|
2月前
|
网络协议 Ubuntu Linux
解决ssh: connect to host IP port 22: Connection timed out报错(scp传文件指定端口)
解决 `ssh: connect to host IP port 22: Connection timed out` 报错涉及检查 SSH 服务状态、防火墙配置、网络连通性和主机名解析等多个方面。通过逐步排查上述问题,并在 `scp` 命令中正确指定端口,可以有效解决连接超时的问题,确保文件传输的顺利进行。希望本文提供的解决方案能帮助您快速定位并解决该错误。
412 3
|
2月前
|
运维 网络安全
解决ssh: connect to host IP port 22: Connection timed out报错(scp传文件指定端口)
通过这些步骤和方法,您可以有效解决“ssh: connect to host IP port 22: Connection timed out”问题,并顺利使用 `scp`命令传输文件。
1405 7
|
3月前
Visual Studio 快速分析 .NET Dump 文件
【11月更文挑战第10天】.NET Dump 文件是在 .NET 应用程序崩溃或出现问题时生成的,记录了应用程序的状态,包括内存对象、线程栈和模块信息。通过分析这些文件,开发人员可以定位和解决内存泄漏、死锁等问题。在 Visual Studio 中,可以通过调试工具、内存分析工具和符号加载等功能来详细分析 Dump 文件。此外,还可以使用第三方工具如 WinDbg 进行更深入的分析。
150 1
|
7月前
|
存储 运维
使用Visual Studio分析.NET Dump
使用Visual Studio分析.NET Dump
103 0
|
6月前
|
缓存 NoSQL Linux
【Azure Redis 缓存】Linux VM使用6380端口(SSL方式)连接Azure Redis (redis-cli & stunnel)
【Azure Redis 缓存】Linux VM使用6380端口(SSL方式)连接Azure Redis (redis-cli & stunnel)
127 0
|
9月前
|
开发框架 .NET PHP
Web Deploy配置并使用Visual Studio进行.NET Web项目发布部署
Web Deploy配置并使用Visual Studio进行.NET Web项目发布部署
142 1
|
开发框架 .NET 数据库
asp.net企业费用报销管理信息系统VS开发sqlserver数据库web结构c#编程Microsoft Visual Studio
asp.net 企业费用报销管理信息系统是一套完善的web设计管理系统,系统具有完整的源代码和数据库,系统主要采用B/S模式开发。开发环境为vs2010,数据库为sqlserver2008,使 用c#语言开发 应用技术:asp.net c#+sqlserver 开发工具:vs2010 +sqlserver
125 0
|
8月前
|
网络协议
windows_server2012搭建iis并配置http重定向 iis转发
windows_server2012搭建iis并配置http重定向 iis转发
396 1

热门文章

最新文章