Placeholder Image

字幕列表 影片播放

  • Hi, guys, and welcome to the course on Introduction to a SP tart that core 3.1.

  • My name is booking, and I would be our instructor on this introductory course.

  • We will understand the basics off a SP dot net core the reason behind its evolution followed by the new files and four the structure that have Bean introduced.

  • Once we understand that, then we will take a look at new concepts like middle bear routing, tag, helpers, grace of syntax and much more.

  • Now, with ESPN dot net core, there are two ways to build over application.

  • First approach is MBC application, and the second approach is razor pages application.

  • We will be building projects and both the technologies to understand how the basics work.

  • Both the projects will be built with a basic red website, which stands for create, read, update and delete functionality.

  • So we will understand how to connect with data peas and play with Aunt Edie framework in our SP dot net core application.

  • Now, before we start, there are some pre requisites that you should be familiar with, I would say about three months off coding in C sharp and familiarity with basic sequel will be sufficient.

  • Also, if you're stuck with the course, my good will be published on Get Herb Depository so you can always follow along with each lecture.

  • And if there is something which still does not make sense for you, you can always raise a question, and I will be happy to answer that.

  • But the first approach you should take this.

  • Compare your court with my worship on, get up and try to identify.

  • The difference is this way.

  • You will try to identify the others yourself.

  • Now this would be a basic course.

  • Yes, we dot net core, but it will give you a solid foundation before you dive into deeper and complex courses at the end, if you're interested in more detail and in depth courses, I have courses on both NBC as well as razor pages with a SP dot net core, and I would also show you how you can and roll into those courses for the lowest price.

  • That being said, let's get started on this exciting journey to explode the basics off a sp dot net core, and I will see you in the next radio in this course, will be building two projects.

  • First will be a simple razor project, and 2nd 1 will be our main project, which will use M.

  • V.

  • C.

  • So let me demo the first project that will be building.

  • It's a simple book.

  • Wish to raise a project in which, if you select the book tab, it will display less stuff all off the books.

  • Now, here in the list, you can see two types of tables.

  • That is because at the end, here we are using data tables, which makes call off a P I on top here we have a simple table using th and TR tags here.

  • When you create a book, if you try to enter without anything, we have validations.

  • Once you enter the details to create a new book and you hit the create button, it creates the book and this place in both the places here.

  • When we use data tables, if you click added here and if we change something, let me make it a capital W and updated.

  • There you go.

  • You can see it is updated.

  • If you try to delete anything, it will display a sweet alert to you.

  • That being said we have multiple ways.

  • As I was saying before in the creating your book, you'll see a new page card create.

  • But if you go toe absurd, it will be the absurd page.

  • And that will be the same page that we've used to add it.

  • If we go right here, you see, it's absurd.

  • And if you cry here, it will be again an addict page.

  • So this is more of a simplified view.

  • And then at bottom, what we see is more often advanced view.

  • That being said, we are performing crowd operations on our book.

  • But this project is not just that will be learning racing pages and how Paige Model and Page View comes into the picture.

  • So even though this is a small project for crowd operation, that is lots off basic functionalities and basic fine overview that you need to understand that being said, let's take a look at the demo off our final project, which is way more advanced than what you see right here in this radio.

  • Let me walk you through the small project that we will build using M V C.

  • This will be a ready basic project to create great operations on book list.

  • So right here if you go on book lest we will be using their tables to display all off the list from the database, you can add a new book here.

  • You can fill in the details, but let's say if you do not enter name, we see validations that have bean enforced here.

  • That being said, you can create a book and once it is created, you can edit any off the details here and you can also delete book when you delete, we have nice alerts that you can display here and once it is successfully dilated, you will also see nice notifications.

  • So this is a great project to get started with the MBC journey and know what a SP dot net core has to offer in this video.

  • I want to give you a small introduction on a sp dot net evolution a sp dot net Court introduces probably the biggest shift the platform has experienced so far.

  • But let's take a look at how it has evolved over time.

  • In 1996 Microsoft released Framework known as A S P, which stands for actives are our pagers or classic SB with classic KSB.

  • Microsoft made it possible to have server side scripting to dynamic webpages.

  • The biggest revolution came when Microsoft released Dark Night Framework.

  • Microsoft introduced SB Dark Matter Breck forms in 2002.

  • This may creation off backpage, similar to the creation off Windows form.

  • There are a few downsides with wept forms.

  • What forms tried to make state last Web state ful, and in order to do that, it had to make lots of changes to make sure wet pagers retain their states or their values automatically view.

  • States contained those values, and that resulted in a lot off data being generated and transferred with each request sometimes even if it was not required.

  • Web forms waas the first version toe introduce court behind Good behind.

  • It's good, but it makes testing difficult because in one line we are reading from the database, and in the next line we are updating the U.

  • Y.

  • Another common issue.

  • WASP aged lifecycle went requesting a page number off events.

  • We're getting fired.

  • Getting to know all of these events was quite easy to get it wrong.

  • Although there were few downsides, wet forms were generally successful toe get signed up and running quickly.

  • A couple of years later, in 2009 Microsoft released the first version off a SP Dark night M V C.

  • And they tried toe Oh, welcome most off the problems with the forms.

  • It had emphasis on separation of concern.

  • M V C Cool is typically much easier to write.

  • Unit touched four M v.

  • C was the first tradition when they released it as open source.

  • Now, a lot off developers did not like M V C Framework because it had its own flaws when it was created.

  • It was built on top off the competence already created for reforms because off which it was closely tied to system Dark Web, which was tied toe yes and eventually windows.

  • On the other hand, where is evolving quickly, and hence Microsoft had to keep M V C with everything that was changing.

  • Also, M V C was built before Cloud came into the big picture, even though that off M V C applications are still running on cloud.

  • But it is still not built with cloud in mind.

  • Finally, in June, off 2016 Microsoft released a SP dot net core and this was the first worsen.

  • Now a SP dot net core is built on top off the new dark Net core framework.

  • Dark Nat Cole is the very first platform version off dot net and hence it is not tired to just wait knows sp dot net core as compared to the old version off M V C is not tied to the tart net framework.

  • Assemblies like system Not well, yes, Bhagat Netcord team has been very active with the new versions and then in 2017 daily start net core to followed by 2.1 and 2.2 in 28 ing.

  • Finally, in September, off 2019 sp tart Netcord three has been released, which we will be using in this course in this video.

  • Let me show you all the tools that will need for this course.

  • The first and most important is racial Studio 2019.

  • This is the I.

  • D.

  • E that will be using.

  • You can go on with your studio dot Microsoft dot com forward slash me.

  • Yes, and you can tell Note the community worship in for free.

  • Make sure you download the 2019 if it is 2017.

  • Dark Knight Court 3.1 will not work next.

  • What you need is you have to download the dot net cord 3.1 and install it.

  • So if you go on the Microsoft website for Dark Neck or 3.1 here, you can download the windows for X 64 install it once you install it.

  • Then when you create a project in Visual Studio 2019 you will see the dark net core 3.1 option, which ever discuss when we get there.

  • But make sure put off these are installed.

  • After that, you'll have to install the sequel, Server 2019.

  • You can use an older version off sequel server, but I would recommend the latest one.

  • You can download it for free for the Devil A perversion Once you start sequel server.

  • I also want you to inch talk the secrets of our management studio, which will be a U.

  • Y two, your sequel server.

  • So make sure you pinched all on four off these features and that are all the tools that you will need all off the stools are free, so you should not have to spend anything toe installed these software's on your laptop or messed up in this video.

  • I want to show you where you will find all the code that will be building far that one place will be you have to go to broken dot com in there.

  • I have courses.

  • Right now we are on the free course.

  • If you go on the details, if you click course content, it will download the completed code.

  • But if you want lecture by lecture on what was changed, you can click on get help code here it will open up.

  • Put the projects that will be building in this course here.

  • If you see the comments, they will be based on the lecture name inside Razor as well.

  • For each lecture, you will see what exactly waas changed or updated and you can make sure that you have those same things.

  • If you face any issue in a particular lecture so broken dot com And in there you have to go to the course is to find out what course your own and in there in details you will find to get help link in this section we will be creating are ready first project it will be a razor project.

  • And then once we created, we will take a look at the files and folders that are created.

  • With this, we would also understand how an e s p dot net core application is started.

  • And what are the fires that are involved?

  • So let's get started with all of that from the next radio.

  • When you open a publisher Studio 2019 it displays a nice page on the left.

  • Inside, you can see all the projects you were working on and on the right.

  • Inside, you can see options to create a new project.

  • So right here were quick on create a new project.

  • And once you do that, it will display all off the templates that are available out off this we will select a sp dot net court replication.

  • If you do not see on the top few options, you can always search for the temperate on the top.

  • Once you find the a SP Darknet court of a replication, let's hit the next button and we need a project name.

  • Let's call this Booklist Razor and will change the location.

  • I'll page the location, but I want to create this project after that will hit the create button and we'll have more options for our project in here.

  • The first thing to notice it's we have talked that core and the Dark Net framework.

  • We will be using the dark net core and what works and we want to use.

  • We want to use the latest version, which is a sp dot net core 3.1.

  • Once you select that, then we have few templates here.

  • We can go with an empty application and a P I project over application, which uses the razor pagers.

  • Or we can create an application with M V.

  • C.

  • Our mean project will be built using M.

  • V.

  • C.

  • But the first project.

  • I want to give you an introduction to raise their pages here.

  • I will display a crowd operations so that you can get comfortable with razor pages because that will be used inside the identity in our MVC application.

  • So we'll get a basic overview when we built this project.

  • Next we have the authentication here, you can select individual users account for authentication, but right now we do not want to do that because if you do that some off.

  • The things will already be configured for us, but I want to start from scratch in this project, so we'll just create a time application with razor pages.

  • Then, before proceeding will make sure the source is starting at core 3.1, and we'll hit the create pattern for effects.

  • With this, we have created our project and will be taking a look at all the files and folders that we created from the next radio.

  • In this video, we will take a brief overview on what are razor pages.

  • Razor pages have been introduced in sp dot net cord to window, and since then they have become the default way off coding With SP Dark Knight Coach Stack Razor Peaches is a new feature off a SP dot net core that makes coding page focused scenarios more easier and more productive.

  • They provide a simpler way to organize court with a SP dot net core applications, keeping the implementation logic and few mortals closer to the few implementation code.

  • Raising peaches is not just for simple scenarios.

  • Everything that you can do with NBC, you can do the same using razor pages like routing models, action result tag helpers and so on.

  • Finally, razor pages have two parts.

  • First is the U.

  • Y, which is more like the view in M V.

  • C.

  • And then we have the page model, which is a combination off models as well as a few models and the controller action methods.

  • Let me switch back to the application that we just created and give you a quick demo off.

  • Both the compliment.

  • So we are on the Booklist razor.

  • If we go to solution exploded inside pages, we will have the razor pages.

  • Let's take a look at the index page.

  • If you see the index speech has an arrow and very start CIA such TML and Darcy Shtml dots Yes.

  • If you open the doxy Shtml that is the reserve.

  • You all the u Y off razor pages and then the dot c Yes, which is not Samos.

  • The court behind find it is just a naming convention.

  • But this is actually the page model for our index razor page.

  • You can see it extends from the page model class.

  • Inside this page model, we will define the model for this view right here.

  • You can see it is index model and if you go on index, you can see the class name is index model.

  • In here we have handlers, which are like the controller action maker.

  • Right now we only have the get handler that is to find here.

  • But we will be adding a post handler when we wantto post anything from our view or the razor page.

  • Another thing to notice is the name for the get handler.

  • It is prefixed with on key word.

  • Similarly, if you had a bushed handler, it would be something like this in which will have public wide on post and will have the implementation within the brackets.

  • We will undo the change that we date because I just wanted to show that right now.

  • But as we proceed with the implementing the handlers for our razor pagers in this video, let's take a look at the Project configuration file in order to open that you can right click on the project not on the solution, but on the project.

  • And you have the addict project file or all you can do is double click on the project name and it will open up the project file the fine name would be the project name and then the extension dot CS Project project file has been there since a long time.

  • But the former it off the file and how it works.

  • It's different In a sp dot net called three in the initial versions off a sp dot net cord we had files card project are Jason and explore AJ.

  • The new C s project file replaces both the file now right here you can see within property group We have the target framework which is not cool at 3.0 which is what we are using for this project.

  • The target framework here is also called a node.

  • After that, we will be adding more packages into our solution.

  • Let me show you a quick way We go to tools Newgate Package manager solution and difficult on brows Let me install any first package that we have We have Newton softer, Jason So we just installed that Don't worry.

  • We'll come back and uninstalled others But I want to show you for demo purposes How the project file will be affected for practice is installed if you go to the project file again Now you see a package reference with Newt and soft Jason.

  • So every time you add a new get package a package where front century would be added here, right now we only have one off them, which we just added.

  • And if we uninstalled us, it will go away.

  • If you go back, this should be gone.

  • Whenever we need to add more packages will be adding more packages.

  • As for our requirement now, if you have worked with previous versions off a SP dark, that core that was a new great format, a package, and let me switch to the presentation for that.

  • And here we were discussing what was the middle package and what is done with that?

  • The package has been discontinued and now it is a part off the dart mad core class library.

  • They're now updated automatically when you update the version off dot net core prior 23.0, as I said before, the matter package was included as a new get package.

  • But now when you install dot net core on your windows or laptop that matter, packages in start automatically.

  • Also, some off the packages have been moved out from that matter package like Entity Framework Core, which has been moved to its own new get package, which we will be installing in the future radios.

  • So that was a brief overview off where the matter package is now.

  • We taught that gold three, you will no longer see the matter package.

  • Microsoft art has been at court art app.

  • It has been moved within the dark net framework, so it is installed automatically when you install dot net core.

  • So that gives a brief overview off the CS project file.

  • Mainly, it is to reference all off the new get packages and the target framework.

  • In this video, we will be taking a look at the properties in our folder.

  • If you expand the properties, you will see a file called Long setting start.

  • Jason, this file cuts reach your studio.

  • What to do when you press the run button right here on the top.

  • By default.

  • We have few profiles here by default.

  • We have few profiles here.

  • The 1st 1 is the yes Express, which will launch yes Express, which will host the application and start a browser that will hit the U.

  • R.

  • L.

  • It will also set the environment variables to development.

  • In this case, we can detect the environment really a bles and make changes based on that example, if this development will load the full CSS and if it is production, then we will load the men ified version off CSS.

  • There is also a section to conficker the yes express Here you can set the launch radia bols here.

  • If you scroll down further, we have another profile called as Booklist Ways.

  • Er richest the project name.

  • It will run the application as a command line application.

  • So the internal cash room, which is internal web server, would be used.

  • Then a browser would be started, which hits the U.

  • R L.

  • These can also be set by going into the property's off the project, not the solution.

  • And if we go on debug, we have all the profiles right here and you can set the environment variables.

  • You were oh, SSL and other configuration.

  • We will not be altering any off this, but I wanted to show you an overview off what it is and where you can change that.

  • Also inside the run here you will see all the profiles so you can select anyone toe Run your application.

  • The next thing that will be taking a look.

  • It's the www root folder.

  • If you expand this, you will see folders for CSS Js level.

  • This is a new thing that has been introduced with a SP dot net core, and this has been created automatically in this folder.

  • B will be placing all the static files like images CSS, JavaScript and also static.

  • HTML.

  • This folder is the root folder for our website.

  • None off the cold files that will be creating will go inside this folder, so you shouldn't be placing any C sharp or razor files here.

  • This folder has been created with an idea off having a nice separation between code files and the static files.

  • Since we created the application using MBC template, we can see that visual studio has already placed few bootstrap CSS and other static fights for us, if you experience yes, says you see site, Garcia says.

  • With GS, you have sight our chairs.

  • And inside the lip folder, we have bootstrap Jake, Query validations and some other scripts.

  • Now the reason we have all the CSS and JavaScript by default is we created the Web application as a razor page.

  • If we selected an empty application, we would have to have all this files by ourselves.

  • If you want to explore that option, you can go ahead with that.

  • But we're believing right is when will be adding more.

  • CSS or Java script will always do that inside our www root folder.

  • So that is the one place for all of your static files.

  • In this video, people be taking a look at the Pages folder inside our razor project.

  • So the main folder inside any razor project is the Pages folder.

  • In here we will have all the peaches that we want for our website.

  • Inside the Pages folder used a shared folder, and if you expand this, we have underscored layout and valuations gets partial.

  • Now the name off these two razor pages starts with an underscore, which means they are partial views.

  • Now, partial pages is something like user components, which means you can reuse them in multiple places in your website.

  • The 1st 1 here, underscored layout, is the default master page for your application.

  • So if you open this up right here, you see, we have the header for our application.

  • You scroll down, we have the main part and we have the footer.

  • We also have the scripts that be worn throughout our application.

  • And if you scroll up right here, we have the CSS files.

  • You can, of course, change the default page that you have for the master page, but we will keep it the same.

  • And right now it is underscored Lee out next.

  • What we have is validation scripts partial here we have just included the child was scripts or J Query that they will use for validations and in the pages where we want to include that.

  • We can just include this partial page after that.

  • Outside off the shared folder, we have the view import now with dot net kowtow pointer when above, we have tag helpers and we will understand in detail about tag helpers in just a little while.

  • But in the view import, you defined that you want to include tag helpers in your application by adding this one line, which starts with act tag helper.

  • You can also add custom tag helpers here if you create your own tag helpers and you want to register for this application.

  • You can also add your custom tag helpers that you want to be used in your application.

  • If for some reason you only want to use tag helpers for some pages, rather than defining this at a global level, you can also define it at individual page.

  • But I like to define it at the global level in underscore view imports so that when I needed it is already present.

  • After that, we have the underscored view start file, and here we define, which is the masterpiece that will use for our application right here, you can see underscored Lee Out has been defined.

  • After that, what we have the rest re are the actual result pages.

  • So you can think about whatever we discuss so far are more related to conflagration, master page and user competent.

  • Then we have the added page index page and the privacy page.

  • Now, if you open up the index Darcy Shtml right here you see the U.

  • Y.

  • Or the user interface with HTML and CSS.

  • But where is the page behind?

  • Or the model defined here?

  • Hey, in every CVI usedto have controllers, but we do not have that anymore in the razor pages.

  • So if you expand this, you see this index dot CSS html dot CS and this is inheriting from page model and the name here is index model.

  • If you go to the index page, you will see the model is the same name.

  • So what, I will be defined inside the page model here will be used as the model for the index razor page.

  • This page model will be a code behind four hour index page.

  • This is nowhere as close to what we had in the classic a sp dot net cord behind this is completely rewritten and in a completely different format, and we will call this dot CS file as the page mortal and the dot CIA.

  • Such the M L will be the view or the razor page.

  • Now that we have a brief overview off rare, what code goes, Let's see rotting in the next video when we will see the index privacy and application coming along one off the top level considerations for the developer off a server side Web application framework is how to match.

  • You are lt's so the resource is on the server so that the correct one processes that request.

  • The most straightforward approach is that human you are else to the physical files on the desk.

  • And this is the approach that has been implemented by the SP dot net core team for razor pages framework.

  • Now there are some rules on how razor pages framework matches you are l two files and how rules can be customized to give different results if needed.

  • The first rule is that Razor Pages needs a root folder by default.

  • The folder has been named pages, and its location is inside the root folder off the Web application project.

  • You can conficker another folder as the root folder in the application conflagration service's matter inside the shot of class.

  • But that is beyond the scope of this course.

  • So we believe that as the default page, if we have any requirements that we had to change that Mabel, of course, take a look at that.

  • Let's switch back to the application that we have right here.

  • You see, the root folder is the pages folder, and all off the pages recites inside that off course.

  • We can add areas here, and we can add pages inside the 80 s folder, then that will become the folder for the application under the rule is that the file extension should not be included inside you are bad.

  • So right here you see indexed artsy shtml inside.

  • There you are.

  • People only mentioned Index.

  • Then let me switch back to the presentation, and the third rule is that indexed.

  • Artsy.

  • Shtml is the default file, which means if a finally is missing from the You are Earl, the request will be mapped to index dot CIA such the ML inside that folder.

  • Now let's take a look at few examples.

  • In the first example, we have www dot domaine dot com.

  • This will map to the pages folder and then look for indexed Arcia.

  • Such the ML page since we have not defined anything in the world Index is the D for Paige.

  • In the second example, we have www dot domaine dot com forward slash index Again.

  • In this, it will look for the same index page inside pages for order because we have explicitly defined the index page.

  • Finally, we have www dot domaine dot com forward slash account.

  • Now here it has two ways to find the page.

  • First, it will try to find inside the pages folder first.

  • It will try to find Inside Pages folder a file named as account Darcy Shtml.

  • If it finds that it will render that if it doesn't find that, then it thinks that account could be a sub folder name under Peaches, so it will check inside the pages folder.

  • If there is a folder called Account and Inside that it will try to find Index Toxie Shtml.

  • So we have few examples here for routing.

  • Let's see this in action.

  • Let's go to our project and run the application In here, you can see the girl is local host and we do not have anything else.

  • So that means by default it is loading the index page.

  • If you go back to our application solution Explorer double quick index, you can see the textures welcome.

  • And that is what we're seeing right here.

  • If he explicitly defined index here, it was still load the same page.

  • Now, if I click on privacy here, you can see it is adding privacy.

  • And if you go back to the solution, privacy is inside pages, so you can directly access that let me stop the application and show you something else.

  • I'll add a new folder and I call this with my name broke in here and I will move privacy inside Brooking.

  • That's what our application and try to access the privacy again.

  • If we click here, it will not let anything because privacy doesn't exist in the same location in orderto access that you have to type of game forward slash privacy.

  • And with this it loads the privacy page correctly.

  • So that way you can see that the linking off all the pages is exactly what you see here.

  • I'll move the privacy back inside the Pages folder and I'll delete my folder, not rename.

  • Perfect.

  • So this was a brief overview on how routing works and will be using more tag helpers and routing.

  • As we proceed with the course.

  • In this video, we will take a look at tag helpers.

  • Tak helpers are brand new to a SP Dark Net core Microsoft look at the success around the other libraries like angular Js, react and others, and decided that implementing an angular directive like experience in the new SB dot net was so important to the adoption off a SP Gartner core and because off which they decided to create tag helpers from ground.

  • Sir.

  • Attack helpers enable souls I kowtow, participate in creating and rendering HTML elements inside the razor files.

  • Though there are similarities between angular directives and tag helpers, there is a major difference.

  • Tank helpers are for single side rendering, while angular Jeez, directors are all about client side rendering.

  • Now you might be wondering how tacky helpers are compared to HTML helpers.

  • If you have worked with previous solutions off that that core HTML helpers are really just methods throughout your razor markup tag.

  • Helpers, on the other hand, are very focused around HD Yemen elements and much more natural to use mount.

  • Let's switch back to the application and let's take a look at phew tag helpers that we already have in here.

  • Let's go on the index page, and we do not have any Tak helpers associate ID inside here.

  • But if we go on underscored layout, there should be plenty of Tak helpers right here.

  • You can see the tack helpers A, S, B, a DEA and SP page.

  • When we have to redirect, tow any off the razor pages.

  • We will use the tag Helper, a SP page and then will define the path right here.

  • We want to go to the index page, which is inside the pages folder.

  • Hence we have to find forward slash index.

  • Then if you scroll down with more navigations, we again have those tag helpers.

  • If you scroll down further right here we have another tack helper, and with the script, we have the SB up and wash in Tak Helper.

  • We will be using more attack helpers for labels, forms and all off the buttons.

  • But we'll do that when we proceed.

  • But the main thing about tag helpers is you can use your regular actually Emma tag, and you can just upend a tag helper like you can with other JavaScript frameworks.

  • Also, I want to show you a few similarities that we have between the HTML helpers and tag helpers.

  • Both HTML helpers and Tak helpers performed the same functionality, but here you can see that the label tag is so not actually animal friendly for HTML helper.

  • But when you use tag Helper, you'll be using the same label tag class attributes on.

  • You have to do is at s before tag hamper.

  • If you do not understand all of this right now, do not worry.

  • As we proceed and start coding, this will start to make much more sense.

  • In classic A SP Dark Net called in the system, Dr Webb, Assembly took care off starting the application and global dot s e x had the methods in which you could provide custom logic.

  • The steps needed to start up an application are now deter mined by you and that starts with the program class file.

  • The program class contains a main method which is the entry point for the application.

  • When the runtime executes the application, it looks for this mean method and cause it more startling applications start up using the main method.

  • The application initially starts as a commander in application.

  • The main method conficker tres sp dot net court and starts it.

  • Let's switch back to the application and take a look at this.

  • So right here will go to solution explorer and we have the program Nazi.

  • Yes, in here.

  • You see, we have a main method here.

  • The configuration is done by calling create host builder, which is a matter In the program class that returns I host builder on that object, build and run is called, and from that point onwards, this application has become an SP dot net core application.

  • Create host builder calls creative art builder on a static Web host class that con figures the Web host using defaults.

  • It deals with the conflagration on how a SP tart netcord deals with Web server configuration files routing and so on.

  • You can see on top off the default conflagration 10 by the create default builder.

  • The Web builder is also conficker to use a startup class file.

  • And if you go on the start of class file by pressing F 12 here, or you can go the solution Exploder started class file right here you can see Start, of course, is a simple class not deriving from any other class.

  • The one time will by convention called to matters Here first is the conficker service is and we have the conficker mattered.

  • Let's take a look at both off them and the start of curse file in the next week.

  • D'oh!

  • As we saw in the previous slip, the runtime executes main, which, among other things.

  • Conficker.

  • It's the start of class.

  • The runtime will call methods.

  • Conficker service is at conficker here.

  • We haven't I con figuration object that is being passed as dependency.

  • Injection tow The Charlotte class here with the conficker service is it is written.

  • This method gets called by runtime.

  • It is used to add service is to the container the purpose off Configure Service's method is too confident Dependency injection dependency injection and classic ESPN dot net waas optional in sp dot net court.

  • It forms an integral part off the PSB Dark Net itself.

  • This method at service is to the application to make them available.

  • You get the service collection object that is injected into the matter as parameter.

  • Now you can use this to build on the service is that would be available to this application examples off the service's would be entity framework, core identity service, M.

  • V.

  • C, and many more.

  • By default, you will have the ad razor pages available.

  • You will not have the razor compilation here, so do not worry.

  • It should look like this.

  • You will only have the ad razor pages and this is because when we created the project.

  • We selected that we want to raise their pagers.

  • The other matter is the conficker method, and here this matter is used to con figure the extra teepee Request pipeline.

  • The pipeline specifies how the application should respond.

  • Toe extra teepee requests.

  • Biplane is composed off individual parts called Middle Bear.

  • Let me switch to a presentation to explain that batter.

  • Now, in any general scenario, what we have is we will have a browser, and then we will have a pipeline in which we will make a request and we will get back a response.

  • The individual parts that make up a pipeline, our card medal bears.

  • Let's consider few off the middle.

  • Where's that we can add in a pipeline.

  • One off them can be M V C.

  • And then we can also add authentication and static files.

  • You should notice that when Viet authentication middle where it should be done before we at NBC and the order is important.

  • The reason is we do not want to Lord M.

  • V.

  • C and then find out that user is not indicated.

  • We also have to conficker middleware for static files in our project like HTML files images CSS or challah script files.

  • Now, when the data drivers through the pipeline, it gets manipulated by individual medal bears and so does the response are the result Let's take a look at a 10,000 foot image off.

  • What happens when this request is made in the next radio?

  • So when the questions made from the browser it first arrives at Webster were like Yeah, yes, I yes.

  • Well, then, in walked the darknet runtime, which would load the C l r.

  • And then look for an angry point in your application, it will find that in the main method off the program class and execute it which starts the internal observer in your application, we will have cash through in our application.

  • The main matter and the started class would configure the application and the request would be routed from I s to Castell and then it will be pushed to the application.

  • After that, it will be processed by all the middle where s and degenerated response will be felt it back to the Castrol which will without it back to the yes that will finally produce the response on the browser.

  • This is much more officiate than the old system.

  • Dark Web approach.

  • Classic System relied heavily on system Dark Web, which was tied to you, yes, but using a pipeline approach, we only plug in the Middle West that we need.

  • Everything we plug in is in a separate assembly exposed in a new get now said system.

  • That world was tied to a yes, and IIs is Type two windows.

  • That is the reason you cannot run classic SB dot net on other observers than you.

  • Yes and Windows Now, since that is no longer the case, yes, but don't net core applications can be run on Web servers and the operating systems.

  • One thing you should keep in mind is that there are two Web servers.

  • One is external like a yes or a party or Lennox.

  • And there is also an internal Web server hosted by your application Request from the External Observer are passed to the internal Web server and other way around.

  • You can choose different internal Web server, but most common is cash through.

  • Since it has first last support in A s begotten.

  • That core cash for is a lightweight Web server, which can only execute the request because off each evening external Web server toe conficker of the options like security hashing.

  • And so one This wasa brief overview on how middle well and pipeline comes to the picture.

  • That means switchback tow the application that we were looking at, an inside the conficker matter.

  • You can see we have planted multiple medal.

  • There's using app and then the middle We're name.

  • We check efforts development.

  • We want to use the developer exception page else.

  • We want to use just a generic better page.

  • Then we have the https redirection middle where we have the middle where for static files because off the static files middle, where we will be able to use the CSS Java script and images that we ever had inside the W W root folder.

  • Then we have to abduct, use routing and then we have abduct use authorization.

  • Finally, we have used end points with dark net go three.

  • They have introduced endpoint routing, in which you can configure multiple routes.

  • We will understand why we need this and we can configure more than one end points here for different technologies which we will see in upcoming radios.

  • But right now the main thing to consider is you can see how we are plugging in different metal wears now.

  • We have used the terminal largely middle where quite a few times.

  • So that's actually understand what middle bears are.

  • Now that we have seen the overview off application flow, let's understand Middle West and pipeline in much more detail.

  • Whenever an extra TB request comes in, something must handle that request so it eventually results in an extra teepee response.

  • Those pieces off code that handles the request and results in a response, make up the request pipeline.

  • What we can do is configured this request pipeline by adding middle wears, which are software compliments that are assembled in tow, an application pipeline to handle requests and response.

  • So typically a browser is going to send a request to your silver, and that request is going to be interpreted by the server and handled by some piece off software.

  • Now, first, that request is attached to something called us.

  • The context object as a part off software that manages this context.

  • In our case, it would be a sp dot net core middle, where you can essentially think off it as a pipeline, which is the city's off pipes that is going to deter mine.

  • What is going to happen to the context?

  • So first the request is passed along the first pipe, and the first pipe interprets the context and checks out the request and determines if there is some type of response needed and attach that to the context.

  • If there is no immediate response that should be handed back to the server, then the context is simply passed along to the next pipe in the pipeline.

  • This continues again to the next piece off the middle, where whatever it might be and it goes on until it reaches the very last pipe.

  • Now it is also possible that at end off the pipeline, no response has been formed, and that will cause a 404 not found and written back to whoever or is native the request.

  • However, it is possible that in anyone or more off this middle wears.

  • That may be a response that needs to be passed back, and it could happen in any off the pipes, so sometimes it could happen.

  • That middle way would not pass the context along the next piece, but Rather says Okay, I have a response that I need to send back.

  • But typically your context will go all the way through the pipeline to the end by the last piece off middleware sensor response which gets back through the pipeline to the server and then the server sends back the response to the browser.

  • This is very simply five portion off how request works.

  • Let me just walk you through that again in a brief overview so that this makes complete sense when the request comes into the server, the server and accesses the dot net core framework and puts the request into a contact stop checked.

  • The context gets passed along through the Middle West.

  • And if a middle where has a response a liver along the way, then it will attach that response to the context object and then passed that context.

  • Object back through the pipeline, do with server, and then the server sends back the response to the problem, sir.

  • Now, keep in mind the order off pipeline is important.

  • It always gets passed from the first to the last.

  • A core example will be authentication middle bear.

  • If the middle where competent finds the request isn't authorized.

  • It was not.

  • Pass it to the next piece off the middle where, but it will immediately return an unauthorized response.

  • It is hence important that authentication middle where is added before other compliments that shouldn't be triggered in case, often unauthorized request.

  • We will be adding more middle ways in our project, but we'll do them as we face the requirement for that.

  • Another file that we have in our project is upsetting.

  • Start Jason.

  • All off the application settings are contained in this file, and any changes to the upsetting start Jason file were required restarting off the ah yes administration to take.

  • In fact, let's switch back to the application and take a look at this file.

  • So if we go here, we have the upsetting start chase on file in here right now.

  • You see, we only have logging.

  • We have large level and few other details.

  • We will be adding more settings here for connection string and also if you add new other details, like maybe something related to dependency.

  • If there are some security keys or anything, you can also add them here.

  • You can also store them remotely on a server, but AB settings is generally a place where you have them when you're initially developing in the future videos, we will be adding more settings here like connection strings, and we'll be accessing this variables inside the start of class file when we use dependency injection.

  • So that's the brief overview off the AB selling stock Chase on file sp dot net course supports dependency injection software design pattern, which is a technique for achieving inversion off control between classes and they're dependencies.

  • Now you might be wondering what is our U.

  • C or inversion off control container?

  • IOC Container is a framework for implementing automatic dependency injection.

  • It manages object creation and its lifetime and also injects dependencies to their class.

  • You see container creates an object off specified class and also inject all off the dependency objects through constructor property or method at runtime and disposes it at appropriate time.

  • This is Stan so that we do not have to create and manage the objects manually.

  • Support for dependents injection is built into a SP dark net core in a SP darknet cool.

  • Both framework service is an application.

  • Service is can be injected into your classes rather than being tightly coupled.

  • Dependency injection is a design pattern in which a class or object has its dependent classes injector rather than creating them directly.

  • Dependency injection can help.

  • Definitely.

  • Lt's decoupled the different pieces off their application.

  • Let's try to see this with an example.

  • We have Bob here who has been thinking about going on a hiking so he makes a list off all the supplies, like maps, flashlights, protein bars, et cetera and puts them in a backpack.

  • Now, next year, when he goes on hiking, he takes the backpack with him.

  • This back acts as a container, so during the hike, whenever he needs anything, he takes it out off the container and you system.

  • This is the simple concept that you put items you will need in a container, and when you need them, it already exists inside a container.

  • Let's understand this in a way that it's more related to coding.

  • Let's imagine our application have three pages, and in each page we will need three functionalities.

  • We need to lock something we need to send email, and we need to save something to our database, so we will need to create objects off these functions in classic days will be creating objects off email, database and lager in the first page.

  • Then we will do the same in the second page and so long.

  • But this is different with dependency injection.

  • Let's take a look at that with dependency injection again.

  • We have the same three pages and we want the same three functionalities or the classes.

  • We have a dependency injection container.

  • What we will do is we will register all the three classes inside our container whenever any page will need anything, we were directly extracted from that container.

  • Rather than creating a new object in individual pages, it is created and register in the container.

  • We only have to use this this way.

  • Container deals with creating, registering and disposing off the objects rather than creating them in every page.

  • This is how efficient dependents injection is compared to the classic approach.

  • Now that our project is created in this section, we will start building all the functionalities in our project.

  • We will first at the model that we want to and push it to databases.

  • After that, we will perform operations on book, lest with that we will complete our project with the razor pages and you will see how everything comes to picture.

  • So let's get started with all of that from the next radio.

  • In this video, we will be installing our first new get package.

  • So for that, let me run the application and show you why we need that package.

  • So when you hit the wrong button, it will load our website and you can see the default layout that we have.

  • We have a home page and a privacy page.

  • Let's go to our home razor page and addict.

  • This text so far that will switch back to our application and we'll go to solution exploded.

  • All of the pages will be inside the pages folder with double click on indexed RCs html.

  • And right here while the application is running, we will add my name, bro.

  • Game here, save it.

  • Go back and refresh.

  • You can see the refresh was successful, but the content here did not change.

  • This was an existing feature before he s begotten that court three.

  • But with three, they have decided to act this auto refresh for the view as a separate package.

  • So we'll stop The application will go to tools Newgate Package manager and manage new get packages for solution Inside the Brow

Hi, guys, and welcome to the course on Introduction to a SP tart that core 3.1.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

學習ASP.NET Core 3.1--新手全科班[教程] (Learn ASP.NET Core 3.1 - Full Course for Beginners [Tutorial])

  • 4 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字