Wednesday, 28 April 2021

Monday, 26 April 2021

angular active gaurd example

 ng g guard <name>

give u 4 different options from that select one

import { Injectable } from '@angular/core';
import { CanActivate, CanActivateChild, CanDeactivate, CanLoad,  Route, UrlSegment, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree }  from '@angular/router';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class GuardNameGuard implements CanActivate, CanActivateChild,  CanDeactivate<unknown>, CanLoad {
  canActivate(
    nextActivatedRouteSnapshot,
    stateRouterStateSnapshot)Observable<boolean | UrlTree>  | Promise<boolean | UrlTree> | boolean | UrlTree {
    return true;
  }
  canActivateChild(
    nextActivatedRouteSnapshot,
    stateRouterStateSnapshot)Observable<boolean | UrlTree>  | Promise<boolean  | UrlTree> | boolean | UrlTree {
    return true;
  }
  canDeactivate(
    componentunknown,
    currentRouteActivatedRouteSnapshot,
    currentStateRouterStateSnapshot,
    nextState?: RouterStateSnapshot)Observable<boolean | UrlTree>  | Promise<boolean | UrlTree> | boolean | UrlTree {
    return true;
  }
  canLoad(
    routeRoute,
    segmentsUrlSegment[])Observable<boolean> | Promise<boolean>  | boolean {
    return true;
  }
}


here i selected all so generated details study needed on this

Friday, 23 April 2021

pages styles

 refet this blog below footer styles

code add styles

angular filter tutorial

  This is sample code how to filter list in an angular



filter in angular

below the working sample

filter example


angular hide header if user not login 

import { Router }  from "@angular/router";


constructor(public router: Router){} 
<nav *ngIf="router.url !== '/login' && router.url !== '/signup'"> // or maybe only 'login'
</nav>

convert basic authentication

 String username = "abc";

String password = "123";

String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1")
.GetBytes(username + ":" + password));
httpWebRequest.Headers.Add("Authorization", "Basic " + encoded);

Thursday, 22 April 2021

pfx file



pfx file upload c#

web apis

 

[Route("~/api/Secrets/{name:string}")]

public string GetSecrets(string uri, string name)

{

var  keyVaultName= name;

var kvUris = $"https://{keyVaultName}.vault.azure.net";

}

if you like to pass the string or id from api then donot use name:string youll get parameter error

use only {name}



Learn asp.net core


asp.net core tutorial

Wednesday, 21 April 2021

asp.net core and angular crud

 here sample example of crud using angular and aps.net 

crud

and here made to cross issue and headers issues using above by creating cs file

sample code


Friday, 16 April 2021

Angular bootstrap tabs

 <ul class="nav nav-tabs">

    <li class="active"><a data-target=".tab-pane" data-toggle="tab">All</a></li>
    <li><a data-target="#tab1" data-toggle="tab">Tab 1</a></li>
    <li><a data-target="#tab2" data-toggle="tab">Tab 2</a></li>
</ul>
<div class="tab-content">
    <div id="tab1" class="tab-pane active">Yeahhh, this is Tab 1.</div>
    <div id="tab2" class="tab-pane active">Yup, yup, this is Tab 2.</div>
</div>

Thursday, 15 April 2021

angular tutorial

 The two-way banana-in-the-box model binding is a special case, but Angular has a few standard ways to bind common things:

  • [disabled]="disabledState": Any attribute can be bound with square brackets.
  • (click)="buttonClick(album)": Events are bound with parenthesis.
  • #form1="ngForm": Element name bindings
  • *ngXX: Directives like *ngIf and *ngFor
  • {{album.title}}: Inline expression bindings


Wednesday, 14 April 2021

Angular data bind

 


signIn(provider) {
    this._auth.login(provider).subscribe(
      (data) => {
        console.log(data);
        this.hideForm = false;

        this.emaill = data.email;
        this.nom = data.last_name;
        this.prenom = data.first_name;
        this.profileImage = data.image;
    })
}
 error TS2339: Property 'email' does not exist on type 'Object'.
solution: Replace (data) with (data : any)


Angular model popup bootstrap

 simple way to work model popup 

Just remove style and aira-hideen attributes then it will work fine in angular

<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
    style="display: none;" aria-hidden="false">

Protect apis using azure certificate

 This is tutorial of how to protect our apis from certificate generated in  azure keyvault. accessing the certificate using thumbprint 

1.read api with azure certificate and basic authentication

                           [Route("~/api/test")]
public string GetcustomField ()

{

string thumbprint = "CA3655E816A1CBF11F7CFC6A97E28A371366B190";

X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);

store.Open(OpenFlags.ReadOnly);

X509Certificate2Collection certificates = store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false);

X509Certificate2 certificate = certificates[0];

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://api.entrust.net/enterprise/v2/organizationalUnits");

req.Method = WebRequestMethods.Http.Get;

req.Headers.Add("Authorization", "Basic OTU3Y2NkMThiMi00NjU0OTYyMjomSDdEVStXRDkhQiFPUFNCUkI3SQ==");

req.ClientCertificates.Add(certificate);

var httpResponse = (HttpWebResponse)req.GetResponse();

using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))

{
return streamReader.ReadToEnd();

}

}


Wednesday, 7 April 2021

Div hide based on dropdown value

  <div class=" col-sm-6">

              <kendo-dropdownlist [defaultItem]="'Select item...'"  [data]="RevocationReasons"[valuePrimitive]="true"[(ngModel)]="selectedValue">
              </kendo-dropdownlist>
          </div>
 <div *ngIf="selectedValue==='Key Compromised' ">
</div>

hide or show div based on the dropdown selected value

Friday, 2 April 2021

Angular Navigation

 <ul class="nav navbar-nav">

  <li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact:true}">
    <a [routerLink]="['/']">Home</a>
  </li>
  <li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact:true}">
    <a [routerLink]="['/about']">About</a>
  </li>
  <li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact:true}">
    <a [routerLink]="['/calendar']">Calendar</a>
  </li>
</ul>
for / active link not working so use exact:true;

7 Common mistakes in Dot Net — You can avoid

  There are many common mistakes made during .NET (ASP.NET, .NET Core) development, which affect performance, security, and code… Code Crack...