zoukankan      html  css  js  c++  java
  • 【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.)

    当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

  • 相关阅读:
    echarts模拟highcharts实现折线图的虚实转换
    Chrome开发者工具详解 (5):Application、Security、Audits面板
    Chrome 开发者工具详解(4):Profiles 面板
    Chrome开发者工具详解(3):Timeline面板
    Chrome 开发者工具详解(2):Network 面板
    Chrome开发者工具详解(1):Elements、Console、Sources面板
    移动前端开发之 viewport 的深入理解
    响应式图片
    JS中的函数节流
    总结oninput、onchange与onpropertychange事件的用法和区别 书写搜索的神奇代码
  • 原文地址:https://www.cnblogs.com/lulight/p/14513799.html
Copyright © 2011-2022 走看看