首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法访问Visual ASP.NET核心调试站点

无法访问Visual ASP.NET核心调试站点
EN

Stack Overflow用户
提问于 2020-10-28 12:31:51
回答 2查看 2.2K关注 0票数 2

我在Windows10PC上开发了VS 2019中的ASP.NET Core2.1Web应用程序。一切正常,在Chrome/IIS中调试没有问题。

我把我的项目复制到了我刚刚开始使用的一台新的Win 10电脑上。

当我尝试在Chrome中用IIS调试这个项目时,我会得到一个错误页面,上面写着:这个站点无法到达.

我遵循了溢出文章中建议的各种修复方法,但似乎没有什么效果。这简直把我逼疯了,浪费了太多时间。我试过所有这些步骤,但没有joy:

  • 禁用防病毒防火墙/保护
  • 检查项目属性(与以前的PC相同)
  • 检查launchSettings.json文件(与以前的PC相同)
  • 删除vs/config文件夹中的applicationhost.config (post说该文件将在重建时重新创建,但在重新生成文件之后仍然不存在!)
  • 删除obj文件夹并重新生成
  • 删除vs文件夹并重新生成
  • 检查Windows功能(与工作正常的旧PC相同)
  • 更改VS选项/调试:取消选中“启用编辑并继续”复选框
  • 以管理员身份运行cmd : cd "C:\Program (x86)\IIS“IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:44301/ -UseSelfSigned

launchSettings.json文件

代码语言:javascript
运行
复制
launchSettings.json
{
  "iisSettings": {
    "windowsAuthentication": true,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "https://localhost:44301/",
      "sslPort": 44376
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "CanvasWeb": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:61900/"
    }
  }
}

更新

我尝试了以下操作,但仍未解决问题:

  • IIS Express的ran修复
  • 在cert存储区中没有检查证书副本
  • 删除证书使IIS生成新证书
  • 创建了一个新的“测试”项目--同样的问题也会发生。
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-01-23 18:39:35

此问题可能是IIS Express的HTTPS错误。要检查它:创建一个没有Https的新的ASP.NET核心网络应用程序。取消对/deselect应用程序模板取消检查https的配置中https的配置

如果新的web应用程序运行,则是IIS Express HTTPS问题。使用管理员工具运行流动的power外壳代码将解决IIS问题。

代码语言:javascript
运行
复制
# code start
Start-Transcript -Path "$($MyInvocation.MyCommand.Path).log"
try {
    Write-Host "Creating cert resources"
    $ekuOidCollection = [System.Security.Cryptography.OidCollection]::new();
    $ekuOidCollection.Add([System.Security.Cryptography.Oid]::new("1.3.6.1.5.5.7.3.1","Server Authentication")) | Out-Null
    $sanBuilder = [System.Security.Cryptography.X509Certificates.SubjectAlternativeNameBuilder]::new();
    $sanBuilder.AddDnsName("localhost") | Out-Null
    
    Write-Host "Creating cert extensions"
    $certificateExtensions = @(
        # Subject Alternative Name
        $sanBuilder.Build($true),        
        # ASP.NET Core OID
        [System.Security.Cryptography.X509Certificates.X509Extension]::new(
            "1.3.6.1.4.1.311.84.1.1",
            [System.Text.Encoding]::ASCII.GetBytes("IIS Express Development Certificate"),
            $false),
            # KeyUsage
            [System.Security.Cryptography.X509Certificates.X509KeyUsageExtension]::new(
                [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]::KeyEncipherment,
                $true),
                # Enhanced key usage
        [System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension]::new(
            $ekuOidCollection,
            $true),
            # Basic constraints
            [System.Security.Cryptography.X509Certificates.X509BasicConstraintsExtension]::new($false,$false,0,$true)
        )
    Write-Host "Creating cert parameters"
    $parameters = @{
        Subject = "localhost";
        KeyAlgorithm = "RSA";
        KeyLength = 2048;
        CertStoreLocation = "Cert:\LocalMachine\My";
        KeyExportPolicy = "Exportable";
        NotBefore = Get-Date;
        NotAfter = (Get-Date).AddYears(1);
        HashAlgorithm = "SHA256";
        Extension = $certificateExtensions;
        SuppressOid = @("2.5.29.14");
        FriendlyName = "IIS Express Development Certificate"
    }
    Write-Host "Creating cert"
    $cert = New-SelfSignedCertificate @parameters

    $rootStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList Root, LocalMachine
    $rootStore.Open("MaxAllowed")
    $rootStore.Add($cert)
    $rootStore.Close()
    
    Write-Host "Creating port bindings"
    # Add an Http.Sys binding for port 44300-44399
    $command = 'netsh'
    for ($i=44300; $i -le 44399; $i++) {
        $optionsDelete = @('http', 'delete', 'sslcert', "ipport=0.0.0.0:$i")
        $optionsAdd = @('http', 'add', 'sslcert', "ipport=0.0.0.0:$i", "certhash=$($cert.Thumbprint)", 'appid={214124cd-d05b-4309-9af9-9caa44b2b74a}')
        Write-Host "Running $command $optionsDelete"
        & $command $optionsDelete
        Write-Host "Running $command $optionsAdd"
        & $command $optionsAdd
    } 
}
catch {
    Write-Error $_.Exception.Message
}
finally {
    Stop-Transcript
}
# code End

参考资料:使用#26437时HTTPS错误

票数 1
EN

Stack Overflow用户

发布于 2021-01-29 07:36:14

事实上,我遇到了这个问题,并在互联网上做了一些研究,但是,我找不到解决办法。然后,我决定关闭我的防病毒(卡巴斯基互联网安全21.2),并检查它是否能解决问题,之后,一切都开始工作!不幸的是,我找不到负责网络活动的防病毒设置,所以,即使现在,如果我在.NET中测试后端API,我必须关闭防病毒一段时间(

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64572911

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档