Asp.Net Core 2 – Runtime Store

Welcome to the series of core tutorials, in this part we will discuss another new feature that has shipped with core 2.0

Let’s first discuss 2 problems faced by monolithic applications:

  • All packages need to be deployed for application to run correctly and for different target environments there were challenges in picking the right version of package.
  • Since packages are not precompiled the application load time becomes slow

To overcome these issues core 2.0 has introduced the concept of runtime store using which you can package and deploy applications against a known set of packages that already exist in target environments.

Continue reading

Install and running .Net core

Step 1:

Download and install .net core sdk from

if you already have Visual studio installed you can install “Visual Studio 2017 Tools” else install “Windows (x64) Installer” if you want to work from command line only


Step 2:

When setup finishes it will install all required tools and also setup the path variable so that all CLI tools are available via command line

Continue reading

Asp.Net Core 2 – ASP.NET Core metapackage

As you might already be aware core is a platform made of nuget packages. There are different packages targeting different version of frameworks available say .net 4.6, core 1.0,1.1 and 2.0. We generally classify frameworks into 2 categories:

  • Traditional framework e.g. .net 4.6 which includes .Net framework where most of things are predefined and need not be configured
  • Package-based frameworks which are created entirely from scratch by choosing packages as and when required

Package based frameworks are not easy to use and required a different/higher level of understanding of all required packages and most of the .net developers are used to work with predefined templates provided by visual studio.

This problem has been work around by introducing the concept of metapackages which are a collection of commonly used packages required by apps.

In older versions of .net core tools (both project.json and csproj-based tools) by default specified both a framework and a metapackage but in later versions metapackages were tied to specific frameworks . Depending on targeted framework appropriate metapackage is already added to project. This feature is also called as implicit referencing of metapackages. For example

Continue reading

Asp.Net Core 2 – Razor Pages Support

Razor pages support has been added to core MVC which makes coding page-focused scenarios easier and more productive. Razor page support is enabled in Startup.cs file as

public class Startup
    public void ConfigureServices(IServiceCollection services)
        // Includes this line to support for Razor Pages and controllers.

    public void Configure(IApplicationBuilder app)

Continue reading core 2.0 New Features

Microsoft recently announced version 2.0 with lot of new and exciting features and enhancement. This update comes on top of the first version i.e. Core 1.0 also known as 5.0.  To install core 2.0 update:

Install Visual Studio 15.3 or later with the following workloads:

  • ASP.NET and web development
  • .NET Core cross-platform development

Various new features that have been shipped with core 2.0

  • Razor Pages Support
  • NET Core metapackage
  • .NET Standard 2.0
  • Runtime Store
  • Configuration update
  • Logging Update
  • Authentication update
  • Identity Update
  • Kestrel improvements
  • WebListener renamed to HttpSys
  • Hosting startup and Application Insights
  • Automatic use of anti-forgery tokens
  • Automatic precompilation
  • Razor support for C# 7.1

Continue reading

Asp.Net Core FAQs

What is Asp.Net core? core is high scalable, open source version of and can work across platform. It was initially released as Asp.Net 5 and later renamed as Core 1.0. Microsoft has recently launched version 2.0 of core as well. core has been widely used to create cloud based solutions and works great with cloud platforms like Azure and Docker.
What all applications can we create using Asp.Net Core?
We can build web applications, Web Api, IOT apps , Single page apps and as well mobile application backends.
What are the development tools available for core?
We can use below tools for various OS:
a.) Windows –
We can use Visual Studio(Community/Ultimate/Professional/Enterprise) or Visual studio code on windows.
b.) MAC-
Visual Studio for code or Visual Studio for MAC
c.) Linux-
Visual Studio for code or Visual Studio for MAC

Continue reading

Asp.Net MVC 5 – Scaffolding Enhancements

Scaffolding Enhancements

Scaffolding is a feature through which we can generate code automatically using some predefined templates. Asp.Net MVC has built in scaffolding support and feature has been enhanced in MVC 5 by introduction of New Scaffold Menu item.

Let’s try to generate a controller for an existing Model class

public class PersonModel
public int PersonId { get; set; } 

public string PersonName { get; set; } 

public int PersonAge { get; set; }

Continue reading

Asp.Net MVC 5 – Authentication Filters

Authentication Filters

One of a very common question asked in interview is difference between Authentication and Authorization.

Authentication is Who all are allowed to enter site.

Authorization is What all they are allowed to access once they have entered the site.

Before MVC 5 we already had Authorization Filters which we use to control access to resources i.e. whether the current user principle has access to requested resource on server. Continue reading

Asp.Net MVC 5 – Override Filters

Override Fiters MVC 5 provides a way to control which filter applies to which controller or action methods. This can be achieved using Override Filters.

As you might be aware that Filters can be applied to controllers or Actions or Global level. We can apply filters at higher levels usually globally or at controller level and then depending on use we can override them at a lower level i.e. Controller and Action respectively.

Let’s apply Authorize attribute which is an Authorization Filter at Global Level.

public static void RegisterGlobalFilters(GlobalFilterCollection filters)
 filters.Add(new AuthorizeAttribute(){Roles = "Member"});

Continue reading

ASP.Net MVC 5 – Attribute Based Routing Part 1

Attribute Based Routing:

Routing is a process of mapping a virtual or nonexistent URL to a physical resource on server. Url Routing is not a new feature and traces of routing were always available in web forms from version 2.0.

If you have worked on web forms in 2.0 than you must remember the attribute called UrlMapping in web.config. Just to recap how that worked

      <add url="~/cricket" mappedUrl="~/Home/Cricket.aspx"/>

Continue reading

ASP.Net MVC 5 – Attribute Based Routing Part 3

Overriding a Route Prefix

We can override a Route prefix applied at controller level by using “~” character with Route attribute


public class HomeController : Controller



public ActionResult SomeAction(string category)


ViewBag.category = category;

return View();



public ActionResult SomeMoreAction(string category)


ViewBag.category = category;

return View();



Continue reading

ASP.Net MVC 5 – Attribute Based Routing Part 5

Route Constraints

We can restrict the parameters used in routes via Route constraints. There are many route constraints provided by mvc and you can create your custom constraints as well:



[Route("{category:int}",Name = "Test")]

public ActionResult SomeAction(int category)


ViewBag.category = category;

return View();


Continue reading