Skip to main content

Posts

Showing posts from 2018

SignIn Using Facebook Aspnet core 2.2

SignIn Using Social Logins Aspnet core 2.2 https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins?view=aspnetcore-2.2   https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins?view=aspnetcore-2.2 Follow the above link to create an app and get the clientId and secret from google. and AppId and App secret from facebook. Facebook Alone To integrate login using facebook alone just add the below lines  In  ConfigureServices  method  services.AddAuthentication(op=> {                 op.DefaultChallengeScheme = FacebookDefaults.AuthenticationScheme;                 op.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;                 op.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; ...

SignalR with Aspnet core 2.2 and angular6

SignalR with Aspnet core 2.2 and angular6 The SignalR server library is included in the  Microsoft.AspNetCore.App.  Next we need to configure our wepapi  to use it.  in configureservices() section add  services.AddCors(); in the configure method add app.UseCors(builder => builder                 .AllowAnyHeader()                 .AllowAnyMethod()                 .SetIsOriginAllowed((host) => true)                 .AllowCredentials()             ); this is different from core 2.1 as allowanyorigin is not supported with allowcredentials. So we need to either specify which origins to allow for eg: app.UseCors(builder =>             {                 builder.WithOrigin...

Code First Vs Database First (Ef Core 2.1)

Code First Vs Database First (Ef Core 2.1) Seeding the DB          protected override void OnModelCreating(ModelBuilder modelBuilder)         {             base.OnModelCreating(modelBuilder);             modelBuilder.Seed();          } public static class ModelBuilderExtensions     {         public static void Seed(this ModelBuilder modelBuilder)         {             modelBuilder.Entity<Person>().HasData(                 new Person { Id=1,Name = "Anish", Address = "mvlk" }             );             modelBuilder.Entity<Book>().HasData(                 new Book { BookId = 1, AuthorId = 1, Titl...

FLUENT APIS EF Core

FLUENT APIS   Either use annotations or use FLUENT APIS to configure database mappings.. Not everything is possible using annotations. So better to use FLUENT APIS.  modelbuilder.specify<entity>.property in the entity and then use intellesense to use required functionality For Ex; precision of a decimal field cannot be specified using annotations but can be done using FLUENT APIS. Otherwise we need to create a custom data annotation using FLUENT APis and use it in the entity class.

Creating Custom Protocol Links

Custom Protocol Links We can create custom protocol links that can carry out operations as per the configurations For example: <a href="mailto:as@b.c"> Similar to the mailto protocol we can create our own protocol. In my case I created one that would launch an application when this link is clicked. I had to start a project in my solution based on certain conditions. So I created this custom protocol that would start the project based on the requirements. Create an entry in the registry as follows  Add a new string value to the command folder with the path to the .exe file that needs to be launched ex: "C:\mine\sample.exe" "%1". The %1 denotes that we will be passing parameters to the main method . The parameters will be received inside the string[] args in the main Method of the program. Creating a custom MIME TYPE Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\.msg]     @="msg_file" [HKEY_...

Adding Policies ASPNET CORE Identity

Adding Policies ASPNET CORE Identity @using Microsoft.AspNetCore.Authorization @inject IAuthorizationService AuthorizationService include this in viewImports.cshtml page so that this can be accessed across all cshtml pages in that solution @{                 if ((await AuthorizationService.AuthorizeAsync(User, "AdminOnly")).Succeeded)                 {                          <delete-confirmation confirm="deleteConfirm(dataItem)" heading="'Delete Client'" content="'All information related to client will be deleted'" item-to-delete="client"></delete-confirmation>                  }             } add this in the view ____________________________________________________________ Extension method to check if a user contain...