#06 Overview of launchSettings.json file | Introduction to ASP.NET Core | ASP.NET Core MVC Course

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in the last lecture we learned that Kestrel is the default server implementation for asp.net core so when we run this asp.net core application by default it is going to use Castel web server in the background so in this program.cs file as we learned earlier the program.cs is the startup file that means when we run our asp.net core application the execution starts from this file and the first line in this file is the call to the create Builder method this method sets up the Kestrel server as the default server to be used by the application host now how can we verify that to do that let's go to this properties and in there we have this launch settings.json file let's open that file so here this is a Json file in this Json file we have two keys the first key is IIs settings and for that key this object is its value okay this object is its value then we have the second key called profiles and for that profiles key this object is its value now inside this profiles we are setting two profiles HTTP profile and IIs Express profile and these two profiles are basically the servers which we can use for asp.net core project in Windows operating system here I am using Windows operating system so for the Windows operating system we have two servers which we can use in our development one is the Kestrel server and another is the IIs Express server So currently when we are running this project when we are running this application here you can see we have this run button and in front of that run button you will see this http so this HTTP is basically this profile this HTTP profile and this HTTP profile is basically the Castile server then if I click on this drop down here we also have this is Express okay we can also use is Express to run this application so this is Express is basically this is Express profile so now if I go ahead and if I click on this run button it is going to use IIs Express to run this asp.edco application okay so by default here HTTP was selected and this HTTP is our custom server now in.net 6.0 instead of HTTP you will see the project name for example in my case the project name is my first step here I am using dotnet 7.0 but if I would have been using.net 6.0 there instead of profile as HTTP we would have a profile called my first app and here we would have been seeing that text but in dot at 7.0 I think they have changed it to http all right so when we are using this HTTP in order to run this application behind the scenes custom server will be used and for that question server here we are specifying some settings and in these settings if you see both the profiles has this setting called command name so this HTTP also has the setting called command name and this is Express also has this setting called command name so this command name settings plays a very important role if the value of this command name setting is project that means it is Castel server but if the command name is is Express that means it is is server okay so currently here we have selected this HTTP profile that means we have selected Castle server which is the default one for asp.net core so when we run this application on Castel server for that Castile server here we are specifying some settings and one of the settings is this application URL so basically when this application will be run on Kestrel server this will be the URL for the application so in order to access this asp.netco application we will have to type this URL let me go ahead and let me run this application so as you can see when we have run this application we are accessing this application at localhost colon 5136 so this 5136 is the port number on which this application is hosted and it is the same URL which we are specifying here for this HTTP profile here if you see here also the port number is 5136 let me go ahead and let me stop this application and here we can also change the port number so from the 5136 if I want I can change this port number to maybe 4200 or anything like that okay now if I save the changes and now if we run this application now this application should be hosted on localhost port number 4200 if I go ahead and if I run this application now you see the URL is localhost colon port number is 4200. okay so here we can also change the port number on which we want to host our application let me stop the application again and we can also change the profile name okay so basically the profile name here is HTTP but if we want we can change this name to our needs so this HTTP profile is for custom server so we can go ahead and we can name it as Kestrel okay if I save the changes now here instead of HTTP now you should see kestel and if I run this again the application is going to be run on Castel server it is going to use Castel server so you can see the URL is localhost colon port number is 4200 so the application is still running on the Castile server the only thing which we have done is we have changed the name of the profile so that is also possible but this profile is for Castrol server so keep in mind the command name should be project it cannot be changed okay then another profile which we have here is the IIs Express okay so when we use this profile basically from this drop down when we select is Express it is going to use this is Express server to run this application okay and when we use is Express as the server if I scroll up here we have this is settings so here we are actually specifying some settings for the is server so for example here we are specifying the windows authentication as false but if we want Windows authentication we can set it to true okay then here we have some other settings for example the application URL so here the application URL is HTTP colon double slash localhost and port number is double five six one five so when we use is Express to run this application there the URL will be localhost colon double five six one five as the port number let's actually see that let's run this application and this time we are using this is Express so this time the application will be run on is Express and when we are running the application on iOS Express you can see the URL is localhost colon and the port number is double five six one five okay again if you want you can change this port number but always keep in mind that the port number should be greater than one zero two four and it should be less than six double five three five all right now let's briefly have the look over the settings for each of these profiles so when we are using this Kestrel profile earlier it was HTTP I have renamed it to question there we have this command name setting which is set to project so when the command name is project that means that profile is for Castel server then we have another setting.net run message which is set to True basically this settings is used for command line interface of asp.net core project we have learned that we can also use command line interface in order to create and run asp.netco application so when we use command line interface and there when we run some commands it is going to give us some run messages so if we want to see those run messages inside this console application for that we can set this dotted run messages to true if we set it to false in that case we will not get those messages inside this console application all right then we have launch browser so it is set to True basically when we click on any of these profiles so here we are talking about the crystal profile let's go there so basically when I click on this run button it will automatically open a browser and in that browser it will automatically access the application URL okay if we set it to false in that case the server will start but we will have to manually open the browser and then we will have to manually type the URL then we already talked about the application URL it is this URL on which the application will be hosted and can be accessed then we also have this environment variables using this environment variable settings we can set some environment variables for our Kestrel server or for our IIs Express server so if you see for the is Express server also we have this environment variables currently we are setting the environment as development in both the cases but we can also set it to production or we can set it to staged then we have the same settings for IIs Express as well there also we have this command name so here we can change the profile name so here we can change it to something else we can call it IIs or something like that but the command name cannot be changed it should always be is Express if we want to use is Express as the server then the launch browser is set to True again when we have set it to True when we use is Express here in order to run this application it will automatically open the browser and in that browser it will automatically open the application URL and for this is Express the application URL can be found here for this is settings okay so here you can see for the is settings here we have this is Express key to that we are assigning an object in that object we have this application URL key so here the application URL is localhost colon double five six seven five so when we use is Express in order to run this application there the application will be hosted on this URL then here this SSL Port is set to zero that means here we are not using https here we are only using http all right also keep in mind that is Express is a lightweight version of is server both is Express and is supports additional features which are not supported by kestel IIs Express is only available for Windows since I am using Windows operating system here for the development here I have the option of is Express but this is Express is not available if you are using Linux or Mac OS but there you can use nginx or Apache all right so this was a brief overview of this launch settings.json file we use this launch settings.json file to configure the server which we want to use to run our asp.net core application in development okay this is all from this lecture thank you for listening and have a great day
Info
Channel: procademy
Views: 3,038
Rating: undefined out of 5
Keywords: launchSettings.json, asp.net core, mvc, kestrel, iis express, aso.net core mvc tutorial, complete asp.net core mvc course
Id: FgykxrF35XQ
Channel Id: undefined
Length: 11min 28sec (688 seconds)
Published: Mon Jan 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.