{"id":1039,"date":"2016-10-31T09:35:45","date_gmt":"2016-10-31T04:05:45","guid":{"rendered":"http:\/\/stepbystepschools.net\/?p=1039"},"modified":"2016-10-31T09:35:45","modified_gmt":"2016-10-31T04:05:45","slug":"lesson-learnt-configuration-load-issue-in-asp-net-mvc-core-mumbai","status":"publish","type":"post","link":"https:\/\/www.stepbystepschools.net\/?p=1039","title":{"rendered":"Lesson learnt Configuration load issue in ASP.NET MVC core (Mumbai)."},"content":{"rendered":"<p>This is was an interesting problem which we came across in one of our recent ASP.NET MVC Mumbai batches in Andheri.<br \/>\nIn ASP.NET MVC core all settings are stored in Appsettings.Json file.  So one of our students had saved the connection string in the JSON files as shown in the below code.<\/p>\n<pre>{\r\n\"ConnectionString\" :  \"SomeServer\"\r\n}\r\n<\/pre>\n<p>He was reading this configuration data in a class as shown in the below code. This class was dependency injected in all the controllers during the  HTTP request.<\/p>\n<pre>publicclassMyConfiguration\r\n{\r\npublicstring ConnectionString = \u201c\u201d;\r\n}\r\n<\/pre>\n<p>The mapping between the class and the JSON file was done in the configureservices class which is in startup.cs.<\/p>\n<pre>publicvoid ConfigureServices(IServiceCollection services)\r\n{\r\nservices.Configure<MyConfiguration>(Configuration);\r\n\r\n}\r\n<\/pre>\n<p>When the controller was requested the WebAPI was not getting the connection string details. It was coming empty fresh object. After hunting for 15 minutes we found out that the class can not simple variables it should be a SET GET property.<\/p>\n<pre>publicclassMyConfiguration\r\n{\r\npublicstring ConnectionString { get; set; }\r\n}\r\n<\/pre>\n<p>Do not miss our next ASP.NET MVC batch coming week in Mumbai<br \/>\n<a target=\"_blank\" href=\"http:\/\/stepbystepschools.net\/?page_id=315\">http:\/\/stepbystepschools.net\/?page_id=315<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is was an interesting problem which we came across in one of our recent ASP.NET MVC Mumbai batches in Andheri. In ASP.NET MVC core all settings are stored in Appsettings.Json file. So one of our students had saved the &hellip; <a href=\"https:\/\/www.stepbystepschools.net\/?p=1039\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[74,1,3,75],"tags":[44,88,28],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Lesson learnt Configuration load issue in ASP.NET MVC core (Mumbai). - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.stepbystepschools.net\/?p=1039\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Lesson learnt Configuration load issue in ASP.NET MVC core (Mumbai). - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai\" \/>\n<meta property=\"og:description\" content=\"This is was an interesting problem which we came across in one of our recent ASP.NET MVC Mumbai batches in Andheri. In ASP.NET MVC core all settings are stored in Appsettings.Json file. So one of our students had saved the &hellip; Continue reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.stepbystepschools.net\/?p=1039\" \/>\n<meta property=\"og:site_name\" content=\"Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-31T04:05:45+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sukesh Marla\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.stepbystepschools.net\/#website\",\"url\":\"https:\/\/www.stepbystepschools.net\/\",\"name\":\"Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai\",\"description\":\"MVC 5\/Core, AngularJS 1.x, 2.0, 4.0, Design Pattern, Architecture, SSIS, SSAS, SSRS, Data Science, Big data, Hadoop classroom training\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.stepbystepschools.net\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.stepbystepschools.net\/?p=1039#webpage\",\"url\":\"https:\/\/www.stepbystepschools.net\/?p=1039\",\"name\":\"Lesson learnt Configuration load issue in ASP.NET MVC core (Mumbai). - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai\",\"isPartOf\":{\"@id\":\"https:\/\/www.stepbystepschools.net\/#website\"},\"datePublished\":\"2016-10-31T04:05:45+00:00\",\"dateModified\":\"2016-10-31T04:05:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/88d563b9535849b699d9b5efa09d559c\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.stepbystepschools.net\/?p=1039#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.stepbystepschools.net\/?p=1039\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.stepbystepschools.net\/?p=1039#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.stepbystepschools.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Lesson learnt Configuration load issue in ASP.NET MVC core (Mumbai).\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/88d563b9535849b699d9b5efa09d559c\",\"name\":\"Sukesh Marla\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7f960ad602065c0f897d127d81b3adf8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7f960ad602065c0f897d127d81b3adf8?s=96&d=mm&r=g\",\"caption\":\"Sukesh Marla\"},\"sameAs\":[\"http:\/\/www.JustCompile.com\"],\"url\":\"https:\/\/www.stepbystepschools.net\/?author=2\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Lesson learnt Configuration load issue in ASP.NET MVC core (Mumbai). - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.stepbystepschools.net\/?p=1039","og_locale":"en_US","og_type":"article","og_title":"Lesson learnt Configuration load issue in ASP.NET MVC core (Mumbai). - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","og_description":"This is was an interesting problem which we came across in one of our recent ASP.NET MVC Mumbai batches in Andheri. In ASP.NET MVC core all settings are stored in Appsettings.Json file. So one of our students had saved the &hellip; Continue reading &rarr;","og_url":"https:\/\/www.stepbystepschools.net\/?p=1039","og_site_name":"Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","article_published_time":"2016-10-31T04:05:45+00:00","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Sukesh Marla","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.stepbystepschools.net\/#website","url":"https:\/\/www.stepbystepschools.net\/","name":"Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","description":"MVC 5\/Core, AngularJS 1.x, 2.0, 4.0, Design Pattern, Architecture, SSIS, SSAS, SSRS, Data Science, Big data, Hadoop classroom training","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.stepbystepschools.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.stepbystepschools.net\/?p=1039#webpage","url":"https:\/\/www.stepbystepschools.net\/?p=1039","name":"Lesson learnt Configuration load issue in ASP.NET MVC core (Mumbai). - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","isPartOf":{"@id":"https:\/\/www.stepbystepschools.net\/#website"},"datePublished":"2016-10-31T04:05:45+00:00","dateModified":"2016-10-31T04:05:45+00:00","author":{"@id":"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/88d563b9535849b699d9b5efa09d559c"},"breadcrumb":{"@id":"https:\/\/www.stepbystepschools.net\/?p=1039#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.stepbystepschools.net\/?p=1039"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.stepbystepschools.net\/?p=1039#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.stepbystepschools.net\/"},{"@type":"ListItem","position":2,"name":"Lesson learnt Configuration load issue in ASP.NET MVC core (Mumbai)."}]},{"@type":"Person","@id":"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/88d563b9535849b699d9b5efa09d559c","name":"Sukesh Marla","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/7f960ad602065c0f897d127d81b3adf8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7f960ad602065c0f897d127d81b3adf8?s=96&d=mm&r=g","caption":"Sukesh Marla"},"sameAs":["http:\/\/www.JustCompile.com"],"url":"https:\/\/www.stepbystepschools.net\/?author=2"}]}},"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/posts\/1039"}],"collection":[{"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1039"}],"version-history":[{"count":1,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/posts\/1039\/revisions"}],"predecessor-version":[{"id":1040,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/posts\/1039\/revisions\/1040"}],"wp:attachment":[{"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}