In short explained why you should never use Task.Wait() to wait for an asynchronous task to complete from a synchronous context.
The Wait() method always returns an AggregateException if an error occurs within the task execution.
It would be hard to handle the real exception which is wrapped within the AggregateException.
GetAwaiter().GetResult() instead. It will return the real exception.
Using the IIS Manager you can generate self-signed certificates for HTTPS bindings. The certificates generated by the IIS Manager have the limitation that the common name (CN) of the certificate is always the computer name.
If you wish to set an own common name for the certificate, you can use following command in PowerShell (open as administrator) to generate a new self-signed certificate.
New-SelfSignedCertificate -DnsName "my.customdomain.com" -FriendlyName "MyServiceName" -NotAfter (Get-Date).AddYears(10)
Here’s a small but very useful PowerShell script to generate GUIDs in different formats.
You can use this method with PowerShell as alternative to the tail command at Linux.
When using PowerShell, did you ever wish to have a function to pipe structured data to visualize it.
PowerShell has a great built-in function for that:
Out-GridView.You can even filter the rows in the grid.
CSS 3 has a new method calc(), which gives you possibility to align elements. You can mix proportions and fixed measures.
width: calc(100% – 40px);
Recently I’ve found a method GeneratePassword() in the good old .NET full framework, in the System.Web.Security-namespace. It has two parameters to specify the complexity of the password.
; public static string GeneratePassword ( ) int length, int numberOfNonAlphanumericCharacters
Sometimes you write an ASP.NET Core application without using MVC. For example an microservice or an application serving static files.
Anyhow you might want to secure your application using authentication. I was facing the problem, how I could challenge authentication when I’m not using MVC.
The solution is writing a custom middleware that challenges authentication.
If you want the Angular Development Server ng to serve at the external IP of your computer to allow external clients to access the app, use following command.
ng serve --host=0.0.0.0 --disable-host-check
If you want PowerShell to wait for an action to complete, you can display a loading spinner using these few lines of code.
The script will print a new dot every three seconds until the condition in the until-clause is fulfilled.
The result looks like this: