Posts

Showing posts with the label MVC

Migrating database from ASP.NET Identity to ASP.NET Core Identity

Image
As you know ASP.NET Core Identity (table structure) is different from what we had earlier in ASP.NET Identity. Actually the identity system which we have today with .NET Core is very mature and continuously evolved be it ASP.NET Membership, ASP.NET Identity 1, ASP.NET Identity 2 and now ASP.NET Core Identity. Recently I had to migrate few application to ASP.NET Core and similar its identity database. Because the table schema is changed, i had to re-think and create migration script which I would like to share with you today. It is very simple and easy, just three step and I had everything ready: STEP 1 : Change name of existing tables STEP 2 : Create ASP.NET Core Identity tables STEP 3 : Migrate data from old tables (ASP.NET Identity) to new tables (ASP.NET Core Identity) Script:  https://gist.github.com/itorian/c699e8534b392a6c726ec66c48100072 You should also watch my video, where I demoed migration.

Lambda two tables and three tables inner join code samples

In this blog post you will learn inner join using lambda queries. There will be two samples, in first sample you will see how you can join two tables and in second sample you will see how you can extend even further to join three tables and so on. I will sample in-memory data, but the same implementation will work with IQueryable (lazy query) too. Here's the code snippet:- namespace ConsoleApp1 {     class Program     {         static void Main()         {             var table1 = new List<Table1>();             table1.Add( new Table1 { Id = 1, Name = "Name 1" , Address = "Address 1" });             table1.Add( new Table1 { Id = 2, Name = "Name 2" , Address = "Address 2" });  ...

How to move web.config connectionStrings in a separate web.config file ?

In this post you will learn how to create a separate web.config file in ASP.NET or MVC to store development and production versions of connection strings. Step 1. Create a PrivateConn.config file on root with below code < connectionStrings >   < add name = " DataConn1 " connectionString = " Data Source=server;Initial Catalog=database1;Persist Security Info=True;User ID=sa;Password=xxxx;MultipleActiveResultSets=True;App=EntityFramework " providerName = " System.Data.SqlClient " />   < add name = " DataConn2 " connectionString = " Data Source=server;Initial Catalog=database2;Persist Security Info=True;User ID=sa;Password=xxxx;MultipleActiveResultSets=True;App=EntityFramework " providerName = " System.Data.SqlClient " /> </ connectionStrings > Step 2. Open main web.config file (on application root) and then define new config file path, as given below < configuration >   ...

How to move web.config appSettings in a separate web.config file ?

In this post you will learn how to create a separate web.config file in ASP.NET or MVC to store development and production versions of application settings. Step 1. Create a Private.config file on root with below code < appSettings >   < add key = " data1 " value = " value1 " />   < add key = " data2 " value = " value2 " /> </ appSettings > Step 2. Open main web.config file (on application root) and then define file path with appSettings start tag, as given below < configuration >   ....other codes   < appSettings file = " PrivateSettings.config " >     < add key = " webpages:Version " value = " 3.0.0.0 " />     < add key = " webpages:Enabled " value = " false " />     < add key = " ClientValidationEnabled " value = " true " />     < add key = " UnobtrusiveJavaScriptEnabled ...

Slug URL in MVC

Creating a human friendly URL is one of the important goal in content management system. Recently one developer asked me this question. Like he always sees 'id' in URL in MVC application which is not human friendly. He mentioned stack-overflow example when explaining issue to me, so let’s discuss about this. Open stack-overflow page https://stackoverflow.com/questions/40956081 you will be redirected to https://stackoverflow.com/questions/40956081/runtime-exception-thrown-when-stdvector-destructing Notice the last part in the query, this is nothing but a slug that is being added in URL all the time. Technically both URL maps to same resource. And in URL number '40956081' is unique identifier. I hope you know Stack-Overflow is also build using ASP.NET MVC. Let's build similar slug and similar behavior in your MVC application. First you need to configure your route as give below: public static void RegisterRoutes(RouteCollection route...

Azure Media Service Encoding with custom presets

Image
In this post you will learn how to use custom preset for Azure Media Service Encoding. But before that let's look at a case study or issue which I faced. When I uploaded a 55.5 MB mp4 file and encoded with "H264AdaptiveBitrateMP4Set720p" encoder preset, I received following output files: Look into green rectangular highlighted video files in the image, this looks good according to input file size. But if you look at red rectangular highlighted video files, these are *improved* files for adaptive streaming, which looks useless if you compare with my example "a dark line on my face in video can't be removed by system automatically...make sense". Here I'm trying to understand Azure Media Services encoding permutations but increasing file size 2-3 times larger than input file is never a acceptable deal. Why I should pay more for bandwidth and storage on these large files, how I convince my clients? On this issue I thought to under...

Popular posts from this blog

Migrating database from ASP.NET Identity to ASP.NET Core Identity

Customize User's Profile in ASP.NET Identity System