Issue
I have following piece of code in my ngOnInit event.
ngOnInit()
{
let Url = window.location.href.trim().toLocaleLowerCase();
if (Url.startsWith("https://"))
{
console.log('HTTPS');
let NewUrl = Url.replace("https://", "http://");
this.document.location.href = NewUrl;
}
}
My aim is that if Url is having HTTPS then I need to redirect to same Url but with HTTP. But this piece of code is not working even though code comes to the HTTPS block. No error or warning is shown either. I already have tried using
- document.location.href
- location.href
- this.router.navigateByUrl
- Injecting DOCUMENT and using this.document.location.href
I am using
- Angular: 7.1.0
- Angular CLI: 7.1.4
- Node: 10.15.3
- OS: win32 x64
- @angular/router: 7.1.4
How to achieve my purpose?
Thanks in advance,
Solution
I had to do this in IIS. No solution worked n JavaScript.
Answered By - Gulfam
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.