Skip to main content


Showing posts from February, 2018

All About Appsettings.json in ASP.NET Core 2.0

As most of you are aware that in ASP.Net Core, we don't have anything called Web.Config, where we use to write our connection strings or application specific settings. Rather, here we have the file named appsettings.json to store similar sort of information. There are few very common use cases where we need to maintain multiple appsettings.json file in a single solution. For example: Multiple application settings per application - When we need to maintain different-different application specific settings based on the application environment. Say, one can have one type of application settings for Development, another type of application settings for Production, another one for Staging, and so on. Needless to mention, all the appsettings file will have different names. To implement inheritance – If there are some common settings between multiple application settings file, in that case developer can come up with a base application settings file and on top of that specific file

Application Initialization and Configuration in ASP.Net Versions

Most of us might have worked upon various versions of ASP.NET and few of you must be aware about the major changes happened in application initialization and configuration phase. In this article, I'll be outlining few of those major changes starting from ASP.NET MVC, ASP.NET Core 1.x and ASP.NET 2.x. In ASP.NET: In an era of ASP.NET (prior to ASP.NET Core releases), loading of the application was handled by IIS or say Inetmgr was the one who use to call web application's entry point wherein Global.asax.cs use to provide the Application_Start()method.Below is the sample code snippet take from file:        public class MvcApplication : System.Web.HttpApplication   {        protected void Application_Start()        {               AreaRegistration.RegisterAllAreas();               FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);               RouteConfig.RegisterRoutes(RouteTable.Routes);               BundleConfig.RegisterBundles(BundleTa

Tip on MVC URL Routing

Recently, one of my colleague asked me a question, in which his routing was not working as expected. Let me mention the exact URL he was giving: URL 1:  http://localhost:port/StudentEnquiries/StudentEnquiries/44" URL 2: http://localhost:port/StudentEnquiries/StudentEnquiries/?StudentID=44  And his code snippet was as below:            public class RouteConfig       {           public static void RegisterRoutes(RouteCollection routes)           {               routes.IgnoreRoute("{resource}.axd/{*pathInfo}");               routes.MapRoute(                   name: "Default",                   url: "{controller}/{action}/{id}",                   defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }               );           }       }      Where he claimed that he didn’t change anything in his Route.Config file and his Controller looks something like this: