Angular PathLocation to Hashlocation

To redirect PathLocation to HashLocation for Angular routing add the following in the config file:

<system.webServer>
	<rewrite>
		<rules>
			<clear />
			<rule name="SSORedirect" stopProcessing="true">
				<match url=".*" />
				<conditions logicalGrouping="MatchAll">
					<add input="{REQUEST_URI}" pattern="^/ng/(\w+)" />
				</conditions>
				<action type="Redirect" url="/#/{R:0}" />
			</rule>
		</rules>
	</rewrite>
</system.webServer>

ERR_CERT_INVALID in Chrome

ERR_CERT_INVALID in Chrome even when the certificate is installed in the local machine.

Fix:
In the Chrome policy (chrome://policy/) you have the “ChromeRootStoreEnabled” policy name.
By setting this policy name to False (by the registry update), solves the issue.
In Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome
Add a DWORD (32 bit) Value named “ChromeRootStoreEnabled” to 0

Angular subscribe Notations

Classic notation

myMethod.subscribe({
    next(myObservable) { console.log('Observable Value: ', myObservable); },
    error(msg) { console.log('Error Getting Observable: ', msg); }
});

Notation with positional arguments

myObservable.subscribe(  
  x => console.log('Observer got a next value: ' + x),  
  err => console.error('Observer got an error: ' + err),  
  () => console.log('Observer got a complete notification')  
);

Pipe notation

this.myMethod
    .Pipe(
        TakeUntil(this.destroyed),
        Filter(myObservable => myObservable == myObservable.myObservableFilter),
        SwitchMap(\_ => this.myMethod2(this.myField1)),
        SwitchMap(\_ => this.myMethod3(this.myField2)),
        CatchError(err => this.myErrorMethod(err))
    )
    .Unsubscribe();

JWT token [PII is hidden] error

Expires: ‘[PII is hidden by default. Set the ‘ShowPII’ flag in IdentityModelEventSource.cs to true to reveal it.]’

When this error occurs during API authentication with a JWT token it means that a security parameter like ‘issuer’ or ‘authorization_endpoint’ is not set or not set correctly.

To view which parameter causes the error (unhide PII) enter following code in the API’s Program.cs:

IdentityModelEventSource.ShowPII = true;

OAuth Access and Refresh Tokens

Why do we need access token and refresh token?

The idea of refresh tokens is that if an access token is compromised, because it is short-lived, the attacker has a limited window in which to abuse it. Refresh tokens, if compromised, are useless because the attacker requires the client id and secret in addition to the refresh token in order to gain an access token.

Insert value into identity column

To insert a DB value into an identity colum you can turn on identity insert on the table like this so that you can specify your own identity values.

SET IDENTITY_INSERT Table1 ON

INSERT INTO Table1
/*Note the column list is REQUIRED here, not optional*/
            (OperationID,
             OpDescription,
             FilterID)
VALUES      (20,
             'Hierachy Update',
             1)

SET IDENTITY_INSERT Table1 OFF 

Angular ngx-translate hosting in Azure

To make ngx-translate work you have to add the .json MIME type to the hosting.

This can be done by adding a Web.congif directly in wwwroot containing:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".json" mimeType="application/json" />
    </staticContent>
  </system.webServer>
</configuration>

Angular i18n hosting in Azure

1. Ensure that your different language index.html files have the right base tag:

<base href=”/en/”>
<base href=”/es/”>
<base href=”/fr/”>

The / on the end is very important, otherwise it won’t work.

This can be done in angular.json by:

“i18n”: {
“sourcelocale”: “en”,
“locales”: {
“es”: {
“translation”: “src/locale/messages.es.xlf”,
“baseHref”: “es/”
}
“fr”: {
“translation”: “src/locale/messages.fr.xlf”,
“baseHref”: “fr/”
}
}

2. Add a web.config in the root folder where the language folders reside:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <httpRedirect enabled="true">
      <add wildcard="/" destination="/en" />
    </httpRedirect>  
    <rewrite>
      <rules>
        <rule name="angular" stopProcessing="true">
          <match url="^(.{2}\/).*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="/{R:1}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

This will redirect the root url requests to the selected language folder.
destination sets default language folder if no language folder is selected to “/en”.


Premiere Pro 2020 audio/video out of sync

Premiere Pro 2020 audio/video looses sync when importing

This happens when the video has variable frame rate (VFR).
Premiere Pro 2020 cannot work with this.
You have to convert the video to constant frame rate (CFR).
Media Encoder 2020 cannot convert VFR to CFR.
You can use an open source video transcoder ‘Handbrake’ https://handbrake.fr

In Handbrake select Video tab and select the Constant Framerate radiobutton.
Also default Constant Quality of 22 is low so change it for better video quality.