Posts

Showing posts from March, 2018

JSON Patch in Asp.net Core Webapi

Image
Scenario  Consider following Person entity  { "id": 1, "name": "Sam Kwee", "email": "skwee357@olddomain.com" , "address": "123 Mockingbird Lane", "city": "New York", "state": "NY", "zip": "10001" } If there is a requirement to update email address of the person from "skwee357@ olddomain.com "  to  "skwee357@ newdomain.com " as shown below { "id": 1, "name": "Sam Kwee", "email": "skwee357@newdomain.com", "address": "123 Mockingbird Lane", "city": "New York", "state": "NY", "zip": "10001" } We would generally do an HttpPut operation for such partial updates, which incurs updating the entire Person entity, for a minor change of a property (email in this case) .

Part 1 : Asp.Net Core Authentication Using Identity

Image
Lets set the context Do you remember this control offered by classic Asp.Net This is login control offered by classic Asp.net , which was a popular control .   Different modes of Authentication in classic Asp.net are Windows Authentication . Forms Authentication . Passport Authentication . Which are used to validate the username and password that are keyed in by the end user .  But what about profile information of the logged in user , that is been fetched using  Classic Membership Membership is hard to customize also database schema is designed for SQL Server only to store data for users. Because it uses SQL Server database, it was hard to move data to other data sources, especially to non-relational databases like MongoDB . Simple Membership  Simple Membership is improved version of Classic membership, it provides flexibility to customize user profiles.But Simple Membership still not addressed some other major problems like usage of 

ASP.NET Core AddMvc() Vs AddMvcCore()

Image
Scenario  : In Asp.Net core we can leverage the advantages of MVC like routing,razors etc by injecting the Mvc dependency in the Startup.cs like shown below But when you notice closely we see following ambiguity , AddMvc() and why not AddMvcCore() ??                                                           Lets investigate !!!!                                                     To understand the difference, first lets first dig into these methods  AddMvc  and  AddMvcCore  , yes we can see the implementation of these methods because Asp.net Core is open source  !!! AddMvc() :  AddMvcCore() AddMvc() is adding Authorization, the RazorViewEngine and the JsonFormatters we need to get our output going. And most interesting it is also calling the  AddMvcCore()  method itself, the highlighted part, where as AddMvcCore()  lot shorter and only adding the basic things to get started. But both methods are returning an IMvcCoreB