1

First of all, I use .net core 2.1 to develop a single page application(angular 5). Following the link https://www.hanselman.com/blog/DevelopingLocallyWithASPNETCoreUnderHTTPSSSLAndSelfSignedCerts.aspx

I installed the cert for localhost to run the commands

dotnet dev-certs https

And

dotnet dev-certs https --trust

To run the application, I used two ways. The first way was in Visual Studio 2017 I clicked F5. I found the windows showing the message:

dbug: HttpsConnectionAdapter[1]

Failed to authenticate HTTPS connection.

System.IO.IOException: Authentication failed because the remote party has closed the transport stream. at System.Net.Security.SslState.StartReadFrame(Byte[] butter, Int32 readBytes, AsyncProtocolRequest asyncRequest) at System.Net.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) .....

The second way is I run the command dotnet run to start the application. Sometimes in chrome it shows

warning sockjs.js:2998 WebSocket connection to 'ws://localhost:4200/sockjs-node/173/ypgvodsj/websocket' failed: WebSocket is closed before the connection is established.

Before I use https, it was just fine. However after I installed the localhost cert.., it was bad.

Now even I removed the localhost cert and re-installed it, it is still happening.

So I think that the localhost cert might cause the issue.

My code in Startup.cs

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    else
    {
       app.UseExceptionHandler("/Error");
  
    }

    app.UseHttpsRedirection();
    app.UseStaticFiles();
    app.UseCookiePolicy();

    app.UseMvc();
  }

UPDATE:

In my program.cs

public static void Main(string[] args)
{
     CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
     WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>();

In Configure method of Startup.cs

app.UseSpa(s =>
{
    s.Options.SourcePath = "ClientApp";
    if(env.IsDevelopment())
    {
        s.Options.StartupTimeout = new System.TimeSpan(0, 0, 180);
        s.UseAnagularCliServer(npmScript: "start");
    }
Hello
  • 796
  • 8
  • 30
  • It is impossible to develop an Angular application using the .NET technology. If possible, please, rephrase your expression. :) – Sasuke Uchiha Sep 09 '20 at 16:52
  • I used the article you linked a few days ago to fix the certifications issue on my side. And I did not come over the issue you are describing. But I was using the ASP.NET Core 3. – Sasuke Uchiha Sep 09 '20 at 16:53
  • 1
    Check https://stackoverflow.com/questions/51311583/net-core-2-1-3-ssl-error where the issue happened to be related to Kestrel being used rather than IIS Express. – Aaron Sep 11 '20 at 05:25

1 Answers1

1

Thanks for the comment by @Aaron,

It was "applicationUrl": "https://localhost:5001"

Using the following then it works.

   "applicationUrl": "http://localhost:5000;https://localhost:5001"
Hello
  • 796
  • 8
  • 30