<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Soheil Alizadeh on Medium]]></title>
        <description><![CDATA[Stories by Soheil Alizadeh on Medium]]></description>
        <link>https://medium.com/@xsoheilalizadeh?source=rss-f7ea381f8704------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MXoykVVerverCKD06p9KAA.jpeg</url>
            <title>Stories by Soheil Alizadeh on Medium</title>
            <link>https://medium.com/@xsoheilalizadeh?source=rss-f7ea381f8704------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 11:32:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@xsoheilalizadeh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ASP.NET Core Identity Deep Dive — Stores]]></title>
            <link>https://medium.com/@xsoheilalizadeh/asp-net-core-identity-deep-dive-stores-e0e54291b51d?source=rss-f7ea381f8704------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0e54291b51d</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[repository-pattern]]></category>
            <category><![CDATA[aspnetcore-identity]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Soheil Alizadeh]]></dc:creator>
            <pubDate>Mon, 12 Aug 2019 06:46:35 GMT</pubDate>
            <atom:updated>2019-08-12T06:46:35.512Z</atom:updated>
            <content:encoded><![CDATA[<h3>ASP.NET Core Identity Deep Dive — Stores</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nz-_oIlCBzWuDtpv6yEuvg.jpeg" /></figure><p>In the previous blog, we talked about the ASP.NET Core identity members. In this post, I wanna explain the <strong>Stores </strong>in the ASP.NET Core Identity.</p><h3>Why Identity use Stores?</h3><p>The only reason that I see for using stores in the identity is implementing the <strong>Persistence Layer.</strong></p><h4>What is the Persistence Layer?</h4><p>The Persistence Layer is similar to Data Access Layer and there isn’t any huge difference between them. They’re in the middle of database engines and business logics, in other word you isolate them in other layers (Repository pattern is one of them).</p><p>The advantages of using the Persistence Layer:</p><ol><li>Easy migration when you want to change your data storage</li><li>Encapsulation the database logic</li><li>Using mock data in Testing cases</li></ol><p>So here is a question using the Persistence Layer is a good idea? The answer is yes and no. In some cases that you have to separate the data store logic from the business logic because of the project architecture, it’s a good idea. For example, In Identity, you do not have to use the EFCore and its Providers(SqlServer, MySql, …) maybe you have NoSql data storage like MongoDb and other NoSql databases in the project. But it’s a bad idea when you never change the data storage (<strong>You never change it</strong>).</p><h3>Identity Default Stores</h3><p>In Identity, the default stores are implemented by Entity Framework Core.</p><p>When you enable ASP.NET Core Identity in the project by using AddIdentity, AddIdentityCore, AddDefaultIdentity in the startup class, you still haven’t any Store implementation and you will encounter with exceptions like this:</p><blockquote>An unhandled exception occurred while processing the request.</blockquote><blockquote>InvalidOperationException: Unable to resolve service for type ‘Microsoft.AspNetCore.Identity.IUserStore`1[User]’ while attempting to activate ‘UserManager’.</blockquote><p>The exception says that there’s not any implementation for one of the Store interfaces. To resolve the issue we need to add Entity Framework Core Stores by using the AddEntityFrameworkStores method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8368ca3e674f7dac86161f2c86fa2d02/href">https://medium.com/media/8368ca3e674f7dac86161f2c86fa2d02/href</a></iframe><p>What exactly AddEntityFrameworkStores do?</p><p>Here is the <a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/EntityFrameworkCore/src/IdentityEntityFrameworkBuilderExtensions.cs#L24">source code</a>, if you study it you see that it trying to register its Stores like UserStore and RoleStore in IServiceCollection with the <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-2.2#scoped">scoped lifetime</a>.</p><h3>How to use Custom Stores in ASP.NET Core Identity?</h3><p>You have X or Y datastore in your project, The default store doesn’t support it, don’t worry you can implement your stores.</p><p>If you studied the <a href="https://medium.com/@xsoheilalizadeh/asp-net-core-identity-deep-dive-members-e55f1f12f8a9">previous post</a>, you know that we have some interfaces for Stores. You can use them for your custom implementation such as the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00a2bb303c9da54f2f87b8038ca7aea6/href">https://medium.com/media/00a2bb303c9da54f2f87b8038ca7aea6/href</a></iframe><p>I implemented a simple data store for ASP.NET Core Identity, you can use your database logic in this implementation.</p><p>The customization isn’t ready yet, we need to register the new store in the Identity system with using the AddUserStore method:</p><p>There is another method for RoleStore that is AddRoleStore we use it for registering the custom RoleStore.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab8bd9b5244c9ee6646f605304d065dc/href">https://medium.com/media/ab8bd9b5244c9ee6646f605304d065dc/href</a></iframe><h3>Using The Community Stores</h3><p>There are a lot of Community NuGet packages that represent the Store for different data storages.</p><p><strong>Dapper</strong></p><ol><li><a href="https://github.com/grandchamp/Identity.Dapper">https://github.com/grandchamp/Identity.Dapper</a></li><li><a href="https://github.com/dotnetcore-internal/AspNetCore.Identity.Dapper">https://github.com/dotnetcore-internal/AspNetCore.Identity.Dapper</a></li></ol><p><strong>MongoDB</strong></p><ol><li><a href="https://github.com/tugberkugurlu/AspNetCore.Identity.MongoDB">https://github.com/tugberkugurlu/AspNetCore.Identity.MongoDB</a></li><li><a href="https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore">https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore</a></li></ol><p><strong>RavenDB</strong></p><ol><li><a href="https://github.com/maqduni/AspNetCore.Identity.RavenDB">https://github.com/maqduni/AspNetCore.Identity.RavenDB</a></li><li><a href="https://github.com/JudahGabriel/RavenDB.Identity">https://github.com/JudahGabriel/RavenDB.Identity</a></li></ol><p><strong>Cassandra</strong></p><ol><li><a href="https://github.com/lkubis/AspNetCore.Identity.Cassandra">https://github.com/lkubis/AspNetCore.Identity.Cassandra</a></li></ol><p><strong>Redis</strong></p><ol><li><a href="https://github.com/aguacongas/Identity.Redis">https://github.com/aguacongas/Identity.Redis</a></li></ol><p><strong>Firebase</strong></p><ol><li><a href="https://github.com/aguacongas/Identity.Firebase">https://github.com/aguacongas/Identity.Firebase</a></li></ol><h4>Conclusion</h4><p>In this post, we talked about the stores in ASP.NET Core Identity and why they are used in the Identity system. In the end, we’ve learned how we can build our Stores.</p><p><em>English isn’t my main language and I apologize for my grammar mistakes, I appreciate if you tell me the mistakes.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0e54291b51d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Snake-Case Query String in ASP.NET Core]]></title>
            <link>https://medium.com/@xsoheilalizadeh/snake-case-query-string-in-asp-net-core-25fc2d7bdab0?source=rss-f7ea381f8704------2</link>
            <guid isPermaLink="false">https://medium.com/p/25fc2d7bdab0</guid>
            <category><![CDATA[url]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[snake-case]]></category>
            <category><![CDATA[querystring]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <dc:creator><![CDATA[Soheil Alizadeh]]></dc:creator>
            <pubDate>Fri, 12 Jul 2019 12:39:38 GMT</pubDate>
            <atom:updated>2019-08-05T09:56:39.441Z</atom:updated>
            <content:encoded><![CDATA[<p>If you considered having a snake case query string you have some options to implement it in your codes.</p><p>The first option is naming the property or parameter snake case that it’s not a good idea because with this act we violate the c# naming convention.</p><p>Parameter:</p><pre>public IAcitonResult Get(string user_name) =&gt; return Ok();</pre><pre>url: http://ex.com?user_name=soheil</pre><p>Property:</p><pre>public class User<br>{<br> <br>  public string user_name { get; set; }</pre><pre>}</pre><pre>public IAcitonResult Get(User user) =&gt; return Ok();</pre><pre>url: http://ex.com?user_name=soheil</pre><p>But there is another way to have snake-case query string. By using the [FromQuery] attribute in our parameters or properties.</p><p>The [FromQuery] attribute have a Name property and you can use it to defining a snake-case name.</p><p>Parameter:</p><pre>public IAcitonResult Get([FromQuery(&quot;user_name&quot;)]string userName) =&gt; return Ok();</pre><pre>url: http://ex.com?user_name=soheil</pre><p>Property:</p><pre>public class User<br>{<br>  [FromQuery(&quot;user_name&quot;)]<br>  public string UserName { get; set; }</pre><pre>}</pre><pre>public IAcitonResult Get(User user) =&gt; return Ok();</pre><pre>url: http://ex.com?user_name=soheil</pre><p>Now it’s work as well but there is a better implementation which strongly type and you&#39;re not forced to write the snake-case name yourself as a string.</p><p><strong>CustomFromQuery</strong></p><pre>public class CustomFromQueryAttribute : FromQueryAttribute<br>{<br>    public CustomFromQuery(string name)<br>    {<br>        Name = name.ToSnakeCase();<br>    }<br>}</pre><p><strong>StringExtensions</strong></p><pre>public static class StringExtensions<br>{<br> public static string ToSnakeCase(this string o) =&gt; <br>        Regex.Replace(o, @&quot;(\w)([A-Z])&quot;, &quot;$1_$2&quot;).ToLower();<br>}</pre><p><strong>User</strong></p><pre>public class User <br>{    <br>   [CustomFromQuery(nameof(UserName))]    <br>   public string UserName { get; set; } // user_name<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25fc2d7bdab0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ASP.NET Core Identity Deep Dive — Members]]></title>
            <link>https://medium.com/@xsoheilalizadeh/asp-net-core-identity-deep-dive-members-e55f1f12f8a9?source=rss-f7ea381f8704------2</link>
            <guid isPermaLink="false">https://medium.com/p/e55f1f12f8a9</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[identity]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[net-core]]></category>
            <dc:creator><![CDATA[Soheil Alizadeh]]></dc:creator>
            <pubDate>Mon, 25 Feb 2019 12:05:31 GMT</pubDate>
            <atom:updated>2019-08-12T06:47:41.620Z</atom:updated>
            <content:encoded><![CDATA[<h3>ASP.NET Core Identity Deep Dive — Members</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eeWcVD0lRHb9hETGPEyRpw.jpeg" /></figure><p>In the previous <a href="https://medium.com/@soheilalizadeh/asp-net-core-identity-deep-dive-nuget-packages-39bb8187ac45">blog</a> we talked about nuget packages and today we want to study summary of asp.net core identity members.</p><p>In most of APIs that asp.net core identity prepares for us, there are some members of it so that they have hand in the APIs process. Therefore, here we have a list of asp.net core members with an explanation in this blog.</p><h3>Members</h3><ul><li>Stores</li><li>Managers</li><li>Validators</li><li>IdentityOptions</li><li>IdentityErrorDescriber</li><li>Normalizer</li><li>UserClaimsPrincipalFactory</li><li>IdentityResult</li><li>Identity Models</li><li>IdentityBuilder</li><li>Default UI</li></ul><h4>Stores</h4><p>Stores are lower-level classes or interfaces in the asp.net core identity system. they follow repository pattern in themselves. Stores in this system act as a data store and its default data store implemented by Entity Framework Core. we can change the asp.net core identity data store and use another like <a href="https://github.com/grandchamp/Identity.Dapper">Dapper,</a> <a href="https://github.com/tugberkugurlu/AspNetCore.Identity.MongoDB">MongoDB</a> so that we aren’t dependent on using a specific data store.</p><p>If we look at asp.net core identity stores we will see common methods that most of them are CURD operation. here is some note that we should pay attention to them:</p><blockquote><strong>Entity Framework Core acts as a Store in ASP.NET Core Identity.</strong></blockquote><blockquote><strong>Entity Framework Core is the default Store in ASP.NET Core Identity.</strong></blockquote><blockquote>Here is note that is EFCore data store supports by ASP.NET team and <strong>other data store supporting by the community</strong>.</blockquote><p>Following list shows <strong>stores </strong>that are there in the asp.net core system:</p><ul><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IUserStore.cs">IUserStore&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IUserRoleStore.cs">IUserRoleStore&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IUserClaimStore.cs">IUserClaimStore&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IUserEmailStore.cs">IUserEmailStore&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IUserLockoutStore.cs">IUserLockoutStore&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IUserLoginStore.cs">IUserLoginStore&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IUserPasswordStore.cs">IUserPasswordStore&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IUserPhoneNumberStore.cs">IUserPhoneNumberStore&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IUserSecurityStampStore.cs">IUserSecurityStampStore&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IUserTwoFactorRecoveryCodeStore.cs">IUserTwoFactorRecoveryCodeStore&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IUserTwoFactorStore.cs">IUserTwoFactorStore&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IRoleStore.cs">IRoleStore&lt;TRole&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IRoleClaimStore.cs">IRoleClaimStore&lt;TRole&gt;</a></li></ul><p>As default there are some store <strong>implementation</strong>:</p><ul><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Stores/src/UserStoreBase.cs">UserStoreBase</a>( as default without data storage ), this is just for abstraction</li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Stores/src/RoleStoreBase.cs">RoleStoreBase</a>( as default without data storage), this is just for abstraction</li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/EntityFrameworkCore/src/UserStore.cs">EF/UserStore</a>: UserStoreBase ( in Microsoft.AspNetCore.Identity.EntityFrameworkCore)</li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/EntityFrameworkCore/src/RoleStore.cs">EF/RoleStore</a>: RoleStoreBase ( in Microsoft.AspNetCore.Identity.EntityFrameworkCore )</li></ul><p><em>Don’t worry about TUser and TRole, we will talk about them in continue.</em></p><h4>Managers</h4><p>Managers are high-level classes in asp.net core identity system. they act as service in the system and they use data store internally to Implement CRUD operation and more methods for manage identity models. Also other members of asp.net core identity used here like IdentityOptions, Validators, Normalizer, IdentityErrorDescriber, etc.</p><blockquote>In stores usage, managers just use interface of stores for DI and decoupling system’s data store, managers don’t use them directly.</blockquote><p>The Following list shows <strong>managers</strong> that are there in the asp.net core system:</p><ul><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/UserManager.cs">UserManager&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/RoleManager.cs">RoleManager&lt;TRole&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Core/src/SignInManager.cs">SignInManager&lt;TUser&gt;</a></li></ul><p><em>Please open these managers source code and look at their constructor and methods.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wedeh8p-iVJoId7ZjtgCjQ.png" /><figcaption>the graph for better understanding</figcaption></figure><h4>Validators</h4><p>Validators are for identity model validation. they have a <em>ValidateAsync method that gets a </em><strong><em>manager </em></strong><em>and an identity model. we pass them to the ValidateAsync it returns an </em><strong><em>IdentityResult </em></strong>to showing the validation result.</p><ul><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/UserValidator.cs">UserValidator&lt;TUser&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/RoleValidator.cs">RoleValidator&lt;TRole&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/PasswordValidator.cs">PasswordValidator&lt;TUser&gt;</a></li></ul><h4>IdentityOptions</h4><p>IdentityOptions represents all the options we can use to configure the identity system. this options configure in startup (we will study them). the options that are there here are for Claims, User, Password, Lockout, Sign-in, Stores, etc.</p><ul><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IdentityOptions.cs">IdentityOptions</a></li></ul><p><em>its properties:</em></p><ul><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/ClaimsIdentityOptions.cs">ClaimsIdentityOptions</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/UserOptions.cs">UserOptions</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/PasswordOptions.cs">PasswordOptions</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/bfec2c14be1e65f7dd361a43950d4c848ad0cd35/src/Identity/Extensions.Core/src/LockoutOptions.cs">LockoutOptions</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/SignInOptions.cs">SignInOptions</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/StoreOptions.cs">StoreOptions</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/TokenOptions.cs">TokenOptions</a></li></ul><h4>IdentityErrorDescriber</h4><p><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IdentityErrorDescriber.cs">IdentityErrorDescriber </a>is for asp.net core identity system error messages. in this class, there are methods that return IdentityError with a default message and code (the code is for the identity error message). you could localize this class for your main language. the managers use this class to returns an IdentityResult with messages.</p><h4>Normalizer</h4><p>This class is for normalizing a string value and it uses in managers. In some cases when we register a user in the system, the manager uses this for normalizing <strong>UserName </strong>and <strong>Email </strong>value and this is useful for searching or lookup.</p><p><a href="https://github.com/aspnet/AspNetCore/blob/bfec2c14be1e65f7dd361a43950d4c848ad0cd35/src/Identity/Extensions.Core/src/UpperInvariantLookupNormalizer.cs">UpperInvariantLookupNormalizer</a> : <a href="https://github.com/aspnet/AspNetCore/blob/bfec2c14be1e65f7dd361a43950d4c848ad0cd35/src/Identity/Extensions.Core/src/ILookupNormalizer.cs">ILookupNormalizer</a></p><h4>UserClaimsPrincipalFactory</h4><p>This class is for registering user claims as default. it uses mangers and IdentityOptions internally to configure specific claims. the claims like UserName, Roles, UserId gives to the user.</p><h4>IdentityResult</h4><p><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IdentityResult.cs">IdentityResult</a> used in most of asp.net core identity APIs store, manager and other members. this class contains two properties Succeeded, Errors that shows the executed operation status.</p><h4>Identity Models</h4><p>If you look at previous members you see TUser and TRole etc, they are identity models that asp.net core identity used them in the whole of the system. they consist of properties about Users and Roles. The TKey here is the type of primary key for the model that could specific that <strong>if you don’t pass any type it uses string</strong>. Also, there are other type models that you can see them in the following list:</p><ul><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Stores/src/IdentityUser.cs">IdentityUser, IdentityUser&lt;TKey&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Stores/src/IdentityRole.cs">IdentityRole, IdentityRole&lt;TKey&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Stores/src/IdentityUserClaim.cs">IdentityUserClaim&lt;TKey&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Stores/src/IdentityUserLogin.cs">IdentityUserLogin&lt;TKey&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Stores/src/IdentityUserRole.cs">IdentityUserRole&lt;TKey&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Stores/src/IdentityUserToken.cs">IdentityUserToken&lt;TKey&gt;</a></li><li><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Stores/src/IdentityRoleClaim.cs">IdentityRoleClaim&lt;TKey&gt;</a></li></ul><blockquote>These Models aren’t Entity Framework Models <br>or<br>These Models aren’t dependent with Entity Framework</blockquote><h4>IdentityBuilder</h4><p><a href="https://github.com/aspnet/AspNetCore/blob/v2.2.2/src/Identity/Extensions.Core/src/IdentityBuilder.cs">IdentityBuilder</a> is for configuring identity services and with this class, you cloud change or add managers, stores, validators, etc. it used in startup class to configuring asp.net core identity.</p><h4>Default UI</h4><p>This is a default asp.net core web app that uses identity APIs to prepare a complete sample of asp.net core identity that has many features. this full sample is as a <a href="https://docs.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-2.2&amp;tabs=visual-studio">Razor Class Library</a> and it could be a reusable UI. asp.net core identity as default use this UI and if you want custom UI or Implementation don’t use it.</p><p>We’ll study all of these members and learn how we can customize each of them.</p><p><a href="https://medium.com/@xsoheilalizadeh/asp-net-core-identity-deep-dive-stores-e0e54291b51d">Next POST</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e55f1f12f8a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ASP.NET Core Identity Deep Dive — Nuget Packages]]></title>
            <link>https://medium.com/@xsoheilalizadeh/asp-net-core-identity-deep-dive-nuget-packages-39bb8187ac45?source=rss-f7ea381f8704------2</link>
            <guid isPermaLink="false">https://medium.com/p/39bb8187ac45</guid>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[identity]]></category>
            <category><![CDATA[microsoft]]></category>
            <dc:creator><![CDATA[Soheil Alizadeh]]></dc:creator>
            <pubDate>Tue, 19 Feb 2019 21:13:13 GMT</pubDate>
            <atom:updated>2019-02-25T12:07:47.995Z</atom:updated>
            <content:encoded><![CDATA[<h3>ASP.NET Core Identity Deep Dive — Nuget Packages</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_cP2Km8WtXuLbmgFtqlbTA.jpeg" /></figure><p>In the previous <a href="https://medium.com/@soheilalizadeh/asp-net-core-identity-deep-dive-introduction-755dce7e304a">blog </a>we talked about installation and In this blog we going to learn about ASP.NET Core Identity packages.</p><p>Here we have some nuget packages that all of theme related to ASP.NET Core Identity.</p><ul><li><a href="https://www.nuget.org/packages/Microsoft.AspNetCore.Identity/">Microsoft.AspNetCore.Identity</a></li><li><a href="https://www.nuget.org/packages/Microsoft.AspNetCore.Identity.EntityFrameworkCore/">Microsoft.AspNetCore.Identity.EntityFrameworkCore</a></li><li><a href="https://www.nuget.org/packages/Microsoft.AspNetCore.Identity.UI/">Microsoft.AspNetCore.Identity.UI</a></li><li><a href="https://www.nuget.org/packages/Microsoft.Extensions.Identity.Core/">Microsoft.Extensions.Identity.Core</a></li><li><a href="https://www.nuget.org/packages/Microsoft.Extensions.Identity.Stores/">Microsoft.Extensions.Identity.Stores</a></li><li>All in one package (<a href="https://www.nuget.org/packages/Microsoft.AspNetCore.App/2.2.2#">Microsoft.AspNetCore.App</a>)</li></ul><h4>Microsoft.AspNetCore.Identity</h4><p>This package consist Managers, Extensions and some constant classes that helps use to configure asp.net core identity to the a web app. <a href="https://github.com/aspnet/AspNetCore/tree/v2.2.2/src/Identity/Core/src">source</a></p><h4>Microsoft.AspNetCore.Identity.EntityFrameworkCore</h4><p>This package is for implementation of default stores in asp.net core identity that implemented by Entity Framework Core. <a href="https://github.com/aspnet/AspNetCore/tree/v2.2.2/src/Identity/EntityFrameworkCore">source</a></p><h4>Microsoft.AspNetCore.Identity.UI</h4><p>This package consist a default UI for asp.net core identity web app. when you use default UI feature in identity it prepare some razor pages with their implementation. <a href="https://github.com/aspnet/AspNetCore/tree/v2.2.2/src/Identity/UI/src">source</a></p><h4>Microsoft.Extensions.Identity.Core</h4><p>This package consist validators, options, managers and interfaces for stores with some abstract class. <a href="https://github.com/aspnet/AspNetCore/tree/v2.2.2/src/Identity/Extensions.Stores/src">source</a></p><h4>Microsoft.Extensions.Identity.Stores</h4><p>This package consist asp.net core identity models and some abstract class for store. <a href="https://github.com/aspnet/AspNetCore/tree/v2.2.2/src/Identity/Extensions.Stores/src">source</a></p><blockquote>We’ll talk about managers, stores, validators, default UI… in the future blogs and we’ll understand what are theme and what they do.</blockquote><p>You really don’t need to install specific package for asp.net core identity but just when you use or created a asp.net core web app that it have Microsoft.AspNetCore.App. this package contains a collection of packages that we use in your application like Entity Framework Core and here Identity. you cloud see list of its packages <a href="https://www.nuget.org/packages/Microsoft.AspNetCore.App/">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ud_qsi1j0TWTmXsdEDtS3A.png" /></figure><p>But is there a question that is, <strong>when we should install the identity packages?!</strong></p><p>Some times we need to create new projects in our solution, like following solution tree:</p><ul><li>App.Web</li><li>App.Data (class library)</li></ul><p>Here in <strong>App.Data </strong>we force to install the identity packages that we need, cuz here we haven’t any packages like Microsoft.AspNetCore.App for that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t7vAjb5nBgqBBaWr5Wo8Xw.png" /></figure><h3>Community Packages</h3><ul><li><a href="https://www.nuget.org/packages/AspNetCore.Identity.MongoDbCore">AspNetCore.Identity.MongoDbCore</a></li><li><a href="https://www.nuget.org/packages/AspNetCore.Identity.Cassandra">AspNetCore.Identity.Cassandra</a></li><li>…</li></ul><p>Also there are some community packages for asp.net core store these store cloud be a alternative for Entity Framework Core store. asp.net core identity team designed identity store independently so that you cloud have you own data store and you aren’t force to use Entity Framework.</p><p>See you in the <a href="https://medium.com/@soheilalizadeh/asp-net-core-identity-deep-dive-members-e55f1f12f8a9">next blog</a> 🤞❤✔.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39bb8187ac45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ASP.NET Core Identity Deep Dive — Introduction]]></title>
            <link>https://medium.com/@xsoheilalizadeh/asp-net-core-identity-deep-dive-introduction-755dce7e304a?source=rss-f7ea381f8704------2</link>
            <guid isPermaLink="false">https://medium.com/p/755dce7e304a</guid>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[identity]]></category>
            <dc:creator><![CDATA[Soheil Alizadeh]]></dc:creator>
            <pubDate>Sat, 16 Feb 2019 19:32:48 GMT</pubDate>
            <atom:updated>2019-08-13T11:18:01.442Z</atom:updated>
            <content:encoded><![CDATA[<h3>ASP.NET Core Identity Deep Dive — Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VuSiqcefzthYMuANIEYRGg.jpeg" /></figure><p>It’s time that we have an deep dive series for ASP.NET Core Identity that learn to use how ASP.NET Core Identity works and how we can use its powerful feature to have an authentication and authorization system. Also there are too many APIs in ASP.NET Core Identity that let’s use to manage Users, Roles, Claims, etc. In this series I really try to dive in ASP.NET Core Identity and look at all of it members and check its source code in GitHub.</p><p>We use ASP.NET Core Identity 2.2 version for this series and I should say that don’t worry about the next version that released, there aren’t big change in those versions and most of APIs are common. I will check all of changes in the last of series.</p><h3>Content</h3><ul><li><a href="https://medium.com/@soheilalizadeh/asp-net-core-identity-deep-dive-introduction-755dce7e304a">Introduction</a> <em>(current)</em></li><li><a href="https://medium.com/@soheilalizadeh/asp-net-core-identity-deep-dive-nuget-packages-39bb8187ac45">Nuget Packages</a></li><li><a href="https://medium.com/@soheilalizadeh/asp-net-core-identity-deep-dive-members-e55f1f12f8a9">Members</a></li><li><a href="https://medium.com/@xsoheilalizadeh/asp-net-core-identity-deep-dive-stores-e0e54291b51d">Stores</a></li><li><em>In-Progress</em></li></ul><h3>References</h3><p>There are some source that we use theme:</p><ul><li><a href="https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-2.2&amp;tabs=visual-studio">Official Document</a> 😄</li><li><a href="https://github.com/aspnet/AspNetCore/tree/v2.2.2/src/Identity">GitHub — ASP.NET Core Identity Source code</a> 😊</li><li><a href="https://github.com/devSoheilAlizadeh/ASP.NETCoreIdentity">GitHub — Series Source code</a> 😆 ( don’t forget ⭐ )</li></ul><blockquote>There is other source code for ASP.NET Core Identity that is <a href="https://github.com/aspnet/Identity/tree/2.2.0">aspnet/identity</a>, but it’s <strong>read-only</strong> now and ASP.NET team archived it into the <a href="https://github.com/aspnet/AspNetCore/tree/v2.2.2/src/Identity">aspnet/AspNetCore</a>. Also there are an <a href="https://github.com/aspnet/Announcements/issues/320">issue (#320)</a> for this changes and we cloud read all details at there.</blockquote><h3>Installation</h3><p>Here we have 2.2 version of ASP.NET Core Identity so we need to install the .NET SDK that makes use able to use this version.</p><p>Here is the last SDK download link:</p><p><em>.NET Core 2.2.104 —</em><a href="https://dotnet.microsoft.com/download/thank-you/dotnet-sdk-2.2.104-windows-x64-installer"><em> x64 </em></a><em>/ </em><a href="https://dotnet.microsoft.com/download/thank-you/dotnet-sdk-2.2.104-windows-x86-installer"><em>x86</em></a></p><blockquote><a href="https://dotnet.microsoft.com/download/linux-package-manager/rhel/sdk-current">Linux </a>and <a href="https://dotnet.microsoft.com/download/thank-you/dotnet-sdk-2.2.104-macos-x64-installer">macOS </a>installation.</blockquote><p>If you want to know that which versions are installed in you machine run your terminal and execute following command:</p><pre>dotnet --list-sdks</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*am8Nayr9B0slw80cPPWOjQ.png" /></figure><p>Here the output shows list of SDKs that are installed in your machine.</p><p>If you want to get full information about your .NET Core install, use following command:</p><pre>dotnet --info</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PJSrNn5oBX8eUQOFZ4pkKA.png" /></figure><blockquote>If you don’t know about .NET CLI you cloud read its documents <a href="https://docs.microsoft.com/en-us/dotnet/core/tools/?tabs=netcore2x">here</a>.</blockquote><p>So here we’ve done the installation step, And now we need to use an IDE or Editor. Here I’ve prepared the list of them and you cloud chose your option.</p><ul><li><a href="https://visualstudio.microsoft.com/downloads/">Visual Studio 2017</a> / <a href="https://visualstudio.microsoft.com/vs/preview/">2019 (preview)</a></li><li><a href="https://www.jetbrains.com/rider/">JetBrains Rider 2018.3</a></li><li><a href="https://code.visualstudio.com/">Visual Studio Code </a>+ <a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp">OmniSharp</a></li></ul><p>In the next part of series I’ll going to show you members of ASP.NET Core Identity and the structure of that.</p><p>See you in the <a href="https://medium.com/@soheilalizadeh/asp-net-core-identity-deep-dive-nuget-packages-39bb8187ac45">next blog</a> 🤞❤✔.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=755dce7e304a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implement Google reCaptcha in ASP.NET MVC]]></title>
            <link>https://medium.com/@xsoheilalizadeh/implement-google-recaptcha-in-asp-net-mvc-1cd7ba8baca?source=rss-f7ea381f8704------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cd7ba8baca</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[google-captcha]]></category>
            <category><![CDATA[captcha]]></category>
            <category><![CDATA[recaptcha]]></category>
            <category><![CDATA[aspnet-mvc]]></category>
            <dc:creator><![CDATA[Soheil Alizadeh]]></dc:creator>
            <pubDate>Fri, 06 Apr 2018 12:42:58 GMT</pubDate>
            <atom:updated>2018-04-06T12:42:58.006Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi, guys today i have a nuget package that it is for implement Google recaptcha version 2 for ASP.NET MVC Web Apps; it’s my first open source project Please welcome it :).</p><p>First Thing that we most to do is intall the nuget package:</p><pre>Install-Package reCaptcha.Google.Mvc</pre><p>After install nuget pack , time is Config Captcha:</p><p>Go to the global.asax file and Application_Start method config the captcha here you can chose them, they are your language, theme and more customization options:</p><pre>GoogleCaptchaConfiguration.Register(new GoogleCaptchaConfig(CaptchaTheme.Light)<br>{<br>    EnableInDebuggingMode = false,<br>    Secretkey = &quot;yourSecretkey&quot;,<br>    Sitekey = &quot;yourSitekey&quot;,<br>});</pre><blockquote>You can get google captcha keys <a href="https://www.google.com/recaptcha/admin">here</a>.</blockquote><p>Now we can use Google reCaptcha:</p><p>To render Captcha in you view use Html.RenderCaptcha() :</p><pre>@Html.RenderCaptcha()<br>@Html.RenderCaptcha(&quot;siteKey&quot;) // also you set Site key here</pre><p>To render Captcha script use Html.RenderCaptchaScript() this is required:</p><pre>@Html.RenderCaptchaScript()</pre><p>To validation request use GoogleCaptcha action filter on the action method:</p><pre>[HttpPost]<br>[Route(&quot;sing-up&quot;)]<br>[GoogleCaptcha]<br>public ActionResult Register()<br>{<br>    // more code<br>}</pre><p><a href="https://github.com/SoheilAlizade/reCaptcha.Google.Mvc">source code</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cd7ba8baca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to save time on the Twitter?]]></title>
            <link>https://medium.com/@xsoheilalizadeh/how-to-save-time-on-twitter-f0bf84f75a72?source=rss-f7ea381f8704------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0bf84f75a72</guid>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[followers]]></category>
            <category><![CDATA[the-following]]></category>
            <category><![CDATA[twitter]]></category>
            <dc:creator><![CDATA[Soheil Alizadeh]]></dc:creator>
            <pubDate>Fri, 30 Mar 2018 12:13:06 GMT</pubDate>
            <atom:updated>2018-03-30T14:24:19.703Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qVdUUO7LXviHs0-R499-Jg.jpeg" /></figure><p>The number of people who spend time on social networks and for there (followers, likes) is so important and spend a long time to follow, unfollow, fav users or contents. <br>In this post, I want to give you an introduction about same way to saving your time and do operations that I said there in the previous paragraph. these ways Prepared for the Twitter social network. before prepared ways, Let me mention a few points.</p><blockquote>In this case, you must use the web version of Twitter to run scripts on the web app. you need to a browser like chrome, firefox,….</blockquote><blockquote>Twitter has limitation for (follow, unfollow, fav, …) so you need to read twitter docs to Observe the rules. here you can read there “<a href="https://help.twitter.com/en/rules-and-policies/twitter-limits">About Twitter limits</a>”.</blockquote><h4>How to unfollow all users that don’t follow-back to you?</h4><p>In the first case, you need to browser developer tools to toggle it press f12 key.</p><p>After do it go to console tab, like the following image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o_fMVVVrMXCI43AbHX9g_A.png" /></figure><p>Now go to the following tab on your twitter account:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GqvSxTPXYtbC_Xnfr7oELw.png" /></figure><p>Then scroll down to load all users that you follow there, now it’s time to run scripts. To run the script in the button console tab there an input to run them.</p><p>Following script remove all users that followed you:</p><pre>// first remove all users that followed you<br><br>$(&quot;.FollowStatus&quot;).each(function(){<br>    $(this).parents(&#39;.ProfileCard&#39;).remove();<br>});</pre><p>Following script un-follow, all users that don’t follow-back to you with one click:</p><pre>// un-follow all users that  don’t follow-back to you<br><br>$(&#39;.unfollow-text&#39;).click();</pre><h4>How to follow large number of users ?</h4><p>Now you most do previous steps with some change. first go to a user page that you want to follow her or him users, no matter what you use the following or follower tab.</p><p>Following script follow all users that you loaded on the user page:</p><pre>$(&#39;.EdgeButton--secondary.follow-text&#39;).each(function () {<br>    if ($(this).css(&quot;display&quot;) === &quot;block&quot;) {<br>        $(this).click();<br>    }<br>});</pre><h4>How to favorite all tweets in the timeline ?</h4><p>Go to your home or timeline page with previous steps and run following script:</p><pre>$(&quot;.js-actionFavorite&quot;).click();</pre><p>If you don’t want do favorite mentions or retweets on the timeline remove them with following scripts:</p><pre>$(&quot;div[data-has-parent-tweet=&#39;true&#39;]&quot;).remove();</pre><pre>$(&quot;.js-actionFavorite&quot;).click();</pre><p>I hope that this post been Useful to you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0bf84f75a72" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>