ASP.NET Core Tutorial – Session 6 – Environment variable & Hosting Environment

Published: 03 April 2021
on channel: Golden Courses
1,104
8

We allocate this session of ASP.NET Core tutorial to introduce Environment variable and Hosting Envirionment. During this session, we explain about the location and the way of creating Environment Variable. Also, we talk about popular Hosting Environment and go through details of its conditions.

Environment Variable
Environment Variable could be created or edited in launchSettings.json file(we have introduced tis file in session five), operation system or web server. Below you can see the source code of launchSettings.json. The related section has been highlighted. This variable implies the stage of Hosting Environment. It is possible to create an Environment Variable for each launcher profile.

We can also create an Environment Variable in operation system. Bear in mind, if the web server or launchSettings.json file would not be determined at the time of application deployment, the default amount of application safety on operation system or web server would be production. On Windows operation system, we can set this variable from this path: System Properties-Environment Variable. It is completely explained in our video.

Moreover we can create and set Environment Variable on web server. For example in IIS, we have this option in Configuration Editor section of application in system.webServer/aspNetCore. We explain about it in our video.

Value of this Environment Variable can be accessible through Startup Class and Configure method. This method has two parameters that one of them is IWebHostEnvironment and its name is env. Via this parameter we can have access to Environment Variables. Below code explains this matter.

Hosting Environment
Generally, development teams and company separate each development process to three different stages. Development, Staging and Production.

Development Hosting Environment
This stage is for daily application or website development, development team implement their codes and do troubleshooting and debugging during this stage. In development stage we upload none minified CSS and JavaScript files. Also in case of exception, application shows Developer Exception Page that contains technical information which help developer to debug the code.

Staging Hosting Environment
Application or website should be as much as possible same as final production. During this stage we check ant possible deployment issue. Also, we still upload none minified CSS and JavaScript file, but application in case of exception will show user friendly exception page that contains generic message and encourage users to report the problem to site admin or development team. Moreover, during this stage developer team does not do code troubleshooting and debugging.

Production Hosting Environment
This stage is for presenting final production to be used for daily business. We upload minified CSS and JavaScript file in this stage for more security and performance. Moreover, in case of exception, application shows a user friendly page and we should not show developer exception page in this stage. Because, first of all those information are not understandable for users and malicious user can use those information to hack our application.

Tutorial Playlist
https://bit.ly/3lxQP9n

Our Social Media
Facebook: https://bit.ly/310ksqA
Instagram: https://bit.ly/3cOq4th
Telegram: https://bit.ly/3s4mzWc

Text Version of course:
https://www.goldencourses.net/asp-net...


On this page of the site you can watch the video online ASP.NET Core Tutorial – Session 6 – Environment variable & Hosting Environment with a duration of hours minute second in good quality, which was uploaded by the user Golden Courses 03 April 2021, share the link with friends and acquaintances, this video has already been watched 1,104 times on youtube and it was liked by 8 viewers. Enjoy your viewing!