Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Cannot attach to browser to debug blazor WebAssembly when using TLS files

$
0
0

(I also posted this issue in GitHub.)

I am able to debug code in the browser

  • with no TLS
  • when using a standard localhost (e.g. https://localhost:9891) while providing no TLS information.

If I provide my using the default localhost certificate, Blazor debugging does not work, and in some cases the TLS is not served up as expected.

Expected BehaviorWhen for a Blazor-hosted site I use the same TLS settings that work for a standard website, the server will host with TLS just as the ordinary website would, and debug just as is possible when using no TLS or std localhost TLS.

Steps To ReproduceCreate a standard website, to ensure there are no errors involving TLS files.

launch.json:

{"configurations": [    {"name": "straight web","type": "coreclr","request": "launch","preLaunchTask": "build","program": "${workspaceFolder}/bin/Debug/net8.0/StraightWeb.dll","args": [],"cwd": "${workspaceFolder}","stopAtEntry": false,"serverReadyAction": {"action": "openExternally","pattern": "\\bNow listening on:\\s+https?://\\S+","uriFormat": "https://std-dotnet-web.dev.localhost:9891"      },"env": {"ASPNETCORE_ENVIRONMENT": "Development","KESTREL__ENDPOINTS__HTTPSINLINECERTANDKEYFILE__URL": "https://std-dotnet-web.dev.localhost:9891","KESTREL__ENDPOINTS__HTTPSINLINECERTANDKEYFILE__CERTIFICATE__PATH": "C:\\<path>\\localhost.crt","KESTREL__ENDPOINTS__HTTPSINLINECERTANDKEYFILE__CERTIFICATE__KEYPATH": "C:\\<path>\\localhost.key"      },    }  ]}

launchSettings.json:

{"$schema": "http://json.schemastore.org/launchsettings.json","profiles": {"https": {"commandName": "Project","dotnetRunMessages": true,"launchBrowser": true,"applicationUrl": "http://localhost:9891","environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Development"      }    }  }}

Hit F5.browser opens to https://std-dotnet-web.dev.localhost:9891/ and returns (with no TLS errors) "Hello World!"

Now go to a blazor-hosted website:

launch.json:

{"configurations": [    {"name": "Launch and Debug Hosted Blazor WebAssembly App","type": "blazorwasm","request": "launch","hosted": true,"program": "${workspaceFolder}/BlazorApp/BlazorApp/bin/Debug/net8.0/BlazorApp.dll","cwd": "${workspaceFolder}","env": {"ASPNETCORE_ENVIRONMENT": "Development","KESTREL__ENDPOINTS__HTTPSINLINECERTANDKEYFILE__URL": "https://my-cert.dev.localhost:9894","KESTREL__ENDPOINTS__HTTPSINLINECERTANDKEYFILE__CERTIFICATE__PATH": "C:\\<path>\\localhost.crt","KESTREL__ENDPOINTS__HTTPSINLINECERTANDKEYFILE__CERTIFICATE__KEYPATH": "C:\\<path>\\localhost.key"      },"browser": "edge","url": "https://my-cert.dev.localhost:9894"    }  ]}

launchSettings.json:

{"$schema": "http://json.schemastore.org/launchsettings.json","profiles": {"http": {"commandName": "Project","dotnetRunMessages": true,"launchBrowser": true,"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"      }    }  }}

Hit F5Edge opens to about:blank, waits a while, eventually returns failure dialog "unable to launch browser" with a unreadable (incomplete) reference, such as ...:9894/_framework/debug/ws-proxy?browser=ws%3A%2F%2F127.0.0.1%3A51495%2Fdev...

However a new tab can be opened and https://my-cert.dev.localhost:9894 returns with no errors. Also no debugging. Counter increases but no stop is hit.

Now change launch.json:

{"configurations": [    {"name": "Launch and Debug Hosted Blazor WebAssembly App","type": "blazorwasm","request": "launch","hosted": true,"program": "${workspaceFolder}/BlazorApp/BlazorApp/bin/Debug/net8.0/BlazorApp.dll","cwd": "${workspaceFolder}","env": {"ASPNETCORE_ENVIRONMENT": "Development","ASPNETCORE_URLS": "https://*:9893",      },"browser": "edge","url": "https://localhost:9893"    }  ]}

Hit F5. Edge opens to about:blank, waits a few seconds, the URL changes to https://localhost:9893 and debugging in the Counter page functions as expected, with stops honored.

Does anyone see anything obvious that I am doing incorrectly?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>