{"id":670,"date":"2020-07-24T21:02:02","date_gmt":"2020-07-24T20:02:02","guid":{"rendered":"http:\/\/wp.bizoir.dk\/?p=670"},"modified":"2020-07-28T19:39:44","modified_gmt":"2020-07-28T18:39:44","slug":"net-webapp-unable-to-start-kestrel","status":"publish","type":"post","link":"https:\/\/wp.bizoir.dk\/?p=670","title":{"rendered":".Net Webapi &#8211; Unable to start Kestrel"},"content":{"rendered":"<p>While taking some Azure certifications, I have several times experienced this error during some Labs.<\/p>\n<p>After creating a new webapi with<\/p>\n<pre><code>dotnet new webapi --output . --name SimpleApi<\/code><\/pre>\n<p>the ensuing<\/p>\n<pre><code>dotnet run<\/code><\/pre>\n<p>always fails with this error on my Windows 10 development pc.<\/p>\n<pre><code>info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]\r\nUser profile is available. Using \u2018C:\\Users\\XXXX\\AppData\\Local\\ASP.NET\\DataProtection-Keys\u2019 as key repository and Windows DPAPI to encrypt keys at rest.\r\ncrit: Microsoft.AspNetCore.Server.Kestrel[0]\r\nUnable to start Kestrel.\r\nSystem.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.\r\nTo generate a developer certificate run \u2018dotnet dev-certs https\u2019. To trust the certificate (Windows and macOS only) run \u2018dotnet dev-certs https \u2013trust\u2019.\r\nFor more information on configuring HTTPS see https:\/\/go.microsoft.com\/fwlink\/?linkid=848054.<\/code><\/pre>\n<p>The instructions on <a href=\"https:\/\/docs.microsoft.com\/da-dk\/aspnet\/core\/security\/enforcing-ssl?view=aspnetcore-3.1&amp;tabs=visual-studio#trust-the-aspnet-core-https-development-certificate-on-windows-and-macos\">this<\/a> page does not initially help much. As other people also experience, one <code>dotnet dev-certs<\/code> command says no valid certificates exist while another says that one already exists.<br \/>\nWhat have worked for me until now, is to first clear my pc of all existing dev certificates and then generate a new one. I seem to have to do this everytime i create a new project&#8230;<\/p>\n<pre><code>dotnet dev-certs https \u2013clean\r\ndotnet dev-certs https \u2013trust<\/code><\/pre>\n<p>I always comment out the <code>app.UseHttpsRedirection();<\/code> in the autogenerated Startup.cs class, but it does not make any difference.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While taking some Azure certifications, I have several times experienced this error during some Labs. After creating a new webapi with dotnet new webapi &#8211;output . &#8211;name SimpleApi the ensuing dotnet run always fails with this error on my Windows 10 development pc. info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0] User profile is available. Using \u2018C:\\Users\\XXXX\\AppData\\Local\\ASP.NET\\DataProtection-Keys\u2019 as key repository and &hellip; <a href=\"https:\/\/wp.bizoir.dk\/?p=670\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;.Net Webapi &#8211; Unable to start Kestrel&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[13],"class_list":["post-670","post","type-post","status-publish","format-standard","hentry","category-diverse","tag-windows"],"_links":{"self":[{"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/posts\/670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=670"}],"version-history":[{"count":8,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/posts\/670\/revisions"}],"predecessor-version":[{"id":678,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=\/wp\/v2\/posts\/670\/revisions\/678"}],"wp:attachment":[{"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.bizoir.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}