Skip to main content

Posts

Showing posts from 2021

JWT Authentication (ASP.NET Core + Angular) - frontend

 key code snippets are following: guards -> auth.guard import { Injectable } from '@angular/core'; import { ActivatedRoute, ActivatedRouteSnapshot, CanActivate, Router, RouterState, RouterStateSnapshot, UrlTree } from '@angular/router'; import { Observable } from 'rxjs'; import { AuthService } from '../services/auth.service'; @Injectable({   providedIn: 'root' }) export class AuthGuard implements CanActivate {   currentAccessingURL:string;   constructor(public auth: AuthService, public router: Router) {   }     canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {     this.currentAccessingURL = state.url;     let canAccess = this.auth.checkRouteAccessPermission(this.currentAccessingURL);          if (!this.auth.isAuthenticated()) {       this.router.navigateByUrl('/user-login');       return false;     }     else if(!canAc...

JWT Authentication (ASP.NET Core + Angular) - Backend

 Key code  Snippet  are followings Back End: Startup.cs     public class Startup     {         public Startup(IConfiguration configuration)         {             Configuration = configuration;         }         public IConfiguration Configuration { get; }         // This method gets called by the runtime. Use this method to add services to the container.         public void ConfigureServices(IServiceCollection services)         {             services.AddDbContext<PharmaDbContext>(options =>                         options.UseSqlServer(Configuration.GetConnectionString("DBConnection")));             services.AddControllers();         ...

What is Design Pattern?

In software engineering, a software design pattern is a general, reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. -  Wikipedia Christopher Alexander says, "Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice" [AIS+77]. Even though Alexander was talking about patterns in buildings and towns, what he says is true about object-oriented design patterns. Our solutions are expressed in terms of objects and interfaces instead of walls and doors, but at the core of both kinds of patterns is a solution to a problem in a context. In general, a pattern has four essential elements: 1. The pattern name is a handle we can use to describe a design prob...

Evolution of Microsoft's ASP.NET nice short discussion by Dai (stackoverflow)

( This answer is regularly updated whenever a new .NET announcement is made, and it has been updated with details of ASP.NET Core 3.0, .NET 3, and .NET 5 ) Microsoft needs a good slapping for the amount of confusion over the past 3 years 5 years over .NET Core / DNX, ASP.NET Core, .NET Standard, .NET 5 and the rest. (and I'm saying that as a former FTE SE in DevDiv... ("hi from building 16!") ) ASP.NET aka "System.Web" is now dead. WebForms is dead (hurrah!) ASP.NET MVC launched in 2008 was built on-top of ASP.NET, but bypassed most of the WebForms infrastructure. ASP.NET MVC has its own versioning separate from ASP.NET and ASP.NET Web API (and ASP.NET Core ). You linked to ASP.NET MVC 5 's documentation - this is not the same thing as ASP.NET 5 . ASP.NET Web API launched in 2012 is a sibling of ASP.NET MVC , in that it built on-top of ASP.NET too, but had its own class library ( System.Web.Http ) that didn't share much with A...

Cannot access a disposed object. A common cause of this error is disposing a context that was

  Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Object name: 'PropertyContext'.  public class CustomerHub : Hub     {         public readonly ICustomerService _customerService;         private readonly IServiceScopeFactory _serviceScopeFactory;         public CustomerHub(ICustomerService service, IServiceScopeFactory serviceScopeFactory)         {             _customerService = service;             _serviceScopeFactory = serviceSco...