Skip to main content

Posts

Showing posts from January, 2020

Ionic Angular Page Life Cycle Methods

Page Life Cycle Methods: Page life cycle methods are like default method gets executed on navigate to the page. Major life cycle methods in the Ionic application are: ionViewWillEnterionViewDidEnterionViewWillLeaveionViewDidLeave Route Effects On Ionic Page State: In angular <router-outlet> prebuild component where any page will be displayed inside of it dynamically based on route configuration components. Ionic with angular we have route template like <ion-router-outlet> which is extended from <router-outlet>.
On using <ion-router-outlet> ionic navigation work like :- In an ionic application when the user navigates to a new page, ionic will save or store the old page(old page exists within the DOM in the hidden state) and display the new page.Now if the user clicks on the old page link from the current page, ionic loads the old page from the storage(this means components will not be initialized freshly). It is like a cache for performance in mobile devices.Page…

How Response Caching Works In Asp.Net Core

What Is Response Caching?: Response Caching means storing of response output and using stored response until it's under it's the expiration time. Response Caching approach cuts down some requests to the server and also reduces some workload on the server. Response Caching Headers: Response Caching carried out by the few Http based headers information between client and server.
Main Response Caching Headers are like below
Cache-ControlPragmaVary Cache-Control Header: Cache-Control header is the main header type for the response caching. Cache-Control will be decorated with the following directives. public - this directive indicates any cache may store the response.private - this directive allows to store response with respect to a single user and can't be stored with shared cache stores.max-age - this directive represents a time to hold a response in the cache.no-cache - this directive represents no storing of response and always fetch the fresh response from serverno-store…

Endpoint Routing In Asp.Net Core

How Routing Works In  Core 2.1 And Below Versions?: In Asp.Net Core routing is configured using app.UseRouter() or app.UseMvc() middleware. app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); Here in Dotnet Core version 2.1 or below versions on the execution of route middleware request will be navigated appropriate controller matched to the route.

An operation or functionality which is dependent on route URL or route values and that need to be implemented before the execution of route middleware can be done by accessing the route path from the current request context as below
app.Use(async (context, next) => { if(context.Request.Path.Value.IndexOf("oldvehicle") != -1) { context.Response.Redirect("vehicle"); } else { await next(); } }); app.UseMvc(routes => { routes.MapRoute( name: "vehicleRoute", template: "vehicle", defaults:new { …

Ionic Picker Sample Code In Angular

Introduction: Ionic Picker(ion-picker) is a popup slides up from the bottom of the device screen, which contains rows with selectable column separated items.
The main building block of ion-picker as follows: PickerControllerPickerOptions PickerController: PickerController object helps in creating an ion-picker overlay. create(opts?: Opts): Promise<Overlay> PickerController create method helps in create the picker overlay with the picker options
PickerOptions: PickerOptions is a configuration object used by PickerController to display ion-picker.
Single Column Ionic Picker: single.item.picker.ts: import { Component } from "@angular/core"; import { PickerController } from "@ionic/angular"; import { PickerOptions } from "@ionic/core"; @Component({ selector: "single-column-picker", templateUrl:"single.item.picker.html" }) export class SingleItemPicker { animals: string[] = ["Tiger", "Lion", "Elephant"…

Null Response Behaviour In DotnetCore WebAPI

What HttpNoContentOutputFormatter Do? In DotNet Core Web API by default configured with HttpNoContentOutFormatter. When a NULL result is passed to the 'OK()' method in API, the client consuming that API receives status code 204(NO Content Found) without any response, instead of status code 200 with response NULL value. Sample API endpoint:(returns the NULL result)[Route("Test")] [HttpGet] public IActionResult Test() { string result = null; return Ok(result); }API Result:
Returning status 204 is an ideal response for NULL results. But if you want to receive a NULL response with status 200 we can do by removing this HttpNoContentOutputFormatter. Startup.cs:(ConfigureServices method):services.AddControllers(options => { options.OutputFormatters.RemoveType<HttpNoContentOutputFormatter>(); });API Result: Follow Me:FacebookTwitterPinterest

Dotnet Core GraphQL API Authorization

Introduction: GraphQL API Authorization can be done by implementing GraphQL.Validation.IValidationRule. By implementing IValidationRule we have to implement our own custom rules for validating queries. So we can implement our own custom logic for authorization. IValidationRule is the perfect way of implementing authorization because these rules always get executed prior to the query execution.

Here we are going to implement a sample of GraphQL API protecting it by creating claims-based authorization. To know more about GrapQL API Integration In Asp.Net Core Application Click Here. Identity Server4 Token Based Authentication: In this sample, we are going to use token-based authentication by IdentityServer 4. If you want you can use any other authentication type like cookie authentication or OAuth2.0 or Microsoft Login Identity. Click here for Identity Server4 Sample Source Code. Dotnet Core Web API Verify IdentityServer4 Authentication Token: Let's create a Dotnet Core Web API pro…