字幕列表 影片播放 列印英文字幕 Hello everyone and welcome to Learn MVC step by step in 2 days 2 days means 16 hours yes you guessed it right 16 hours so first thing you would ask me that some kind of scammer something absolutely not this is not scam something this is the real thing so next thing you would ask me that hmmm so is it really possible to learn MVC in 16 hours my answer is yes absolutely yes and confidentially yes okay So before we start MVC right we need to go and arrange our environment we need to go and ensure that we have the tools with us the first thing what we should have with us is the ultimate edition so this complete tutorial this complete MVC tutorial is in MVC 5 but it holds too for MVC 4 as well it holds too forMVC 3 as well or MVC 2 also down the line right So first thing is we need to go and get hold of this ultimate edition here you can see I have the Visual Studio which is installed in my computer so ensure that the first thing is you need to go online and serach for microsoft Visual Studio 2013 download so once you go and search Visual Studio Ultimate edition on google right you should actually go and land on to this page here you can see I have highlighted the URL In case you are not landed into that page you can pause this video and you can copy that URL you can type that URL out and get to the right page So now the next thing you would be asking me is that why are you telling us to download this Ultimate Edition and why not free edition like XPlus Edition or must be some kind of a downgraded edition like professional edition This tutorial sincerely very very sincerely aims at making you a true MVC professional So I don't want to lose some features by downloading XPlus edition right And second thing you know if worried about the price watch on that screen watch my screen over there it is clearly written free 90 days trial So here you have 3 months with you 90 days is more than enough to learn any thing in the world right so here you have 90 days before you a Visual Studio and here I am promising you that I am going to teach you MVC in 2 days right i.e. 16 hours so the remaining whatever right 88 days is for you to go and create project if you wish right So why go ahead and why why should we download you know XPlus edition and lose some features let's go ahead learn MVC like a true professional let's use Ultimate Edition Once you have downloaded the ultimate edition and you have installed in you computer you should see on the screen what you see here So click on file here click on new project and click on this web menu over here So once you click on the web menu here you can see a template here saying ASP.NET Web Application You can also see one more sublink inside this web here Visual Studio 2012 So if you click on this you will see some template here and you can see the the MVC 4 template here as well So the first question you know which would come to your mind is this two links over here what is this web and what is this 2012 because if we click on this 2012 you are seeing MVC 4 if we click on this web you are not seeing anything right So what are this two links? Now this tutorial will be using MVC 5 for teaching you MVC but whatever I teach in MVC 5 hold too for MVC 4 as well as MVC 3 and MVC 2 as well okay Now in case you want to do MVC 4 then you need to click on Visual Studio 2012 and you need to use this template over here and in case you want to do MVC 5 then you need to click on this web here and you need to actually go and create this project over here Now this is a big difference between MVC 4 and MVC 5 In MVC 4 if you see you know you have different different templates here for example You can see this is ASP.NET MVC 4 then we have ASP.NET Web forms and other things very quickly before I move ahead with difference between MVC 4 and MVC 5 I want to clarify here something regarding ASP.NET regarding MVC and regarding Web form Lot of people think that ASP.NET is different and MVC is different Absolutely wrong okay First thing our base framework is .NET right From .NET ASP.NET is created so again ASP.NET is a framework for web applications okay From .NET we have various framework you know like we have a windows framework you know we have a web framework So this ASP.NET is a web framework and using ASP.NET microsoft has created web forms and it has created MVC So don't think that MVC is different from ASP.NET MVC uses ASP.NET internally So recaping very quickly So at the base we have our .NET Framework on that top ASP.NET is created for Web Applications and from ASP.NET we have something called as web forms whenever I say old ASP.NET I mean by ASP.NET web form Web Forms has a behind code so if you have ASPX it will have ASPX.cs right So that is our old ASP.NET web forms and this new architecture MVC 4 or MVC 5 whatever you think right is a separate thing So we have web forms and MVC using ASP.NET internally and ASP.NET uses the .NET framework internally So now if logically web forms and MVC belongs to ASP.NET framework then why should we have such kind of separate templates And that's what they had improved in 2013 In 2013 they created only one template for everything You can see here rather than having this templates you know separate manners if you click on web here you can see now it is saying ASP.NET web application and from there you can now go and make a choice say okay now i want to create MVC now i want to create web form now i want to create API whatever it is right So by creating this ASP.NET 1 you know it will avoid lot of confusion you know where people will thinking that ASP.NET is different and MVC is different right So i am going to go and start from this template over here if you wish in case you are into visual studio 2012 you can start from here the steps are almost same okay but let me start with MVC 5 so that's a recent version and it will keep us you know upto date as well right so let us say this is HelloWorld so it's a first program HelloWorld and let say okay Now you can see as i have said that it is one ASP.NET framework you know all of these guys Web forms and MVC they have emerge from the ASP.NET framework So you can see now this second template here is telling me so what you want to do do you want to use web forms do you want to do coding in MVC do you want to do coding in Web API So from here you can see now you can go and make a choice of what things you want in your project So at this moment we are learning MVC So we have to go and select MVC over here so you can see MVC is checked over there that is right and what we will do is because this is our first HelloWorld program you know let's not use any kind of authentication or security mechanism at this moment we will talk about these options later on So what I have done here is i have clicked on this change authentication button here and I have said no authentication right So you can see here I have selected here I have selected MVC i have selected this check box and I am all set and i say just say okay over here so you can see you know the new project is created you can also see the solution of the new project In case you are not seeing the solution click on view here and click on solution explorer So there you can see the complete solution of your MVC project so now I am almost done with 5 minutes of the video I have almost created a solution here but I have still not talked about what is MVC and why MVC For now what we will do is we will talk about this why MVC later on because if I start speaking about why MVC now right itself it will lead to more confusion believe me that okay so what we will do is let's complete 3 or 4 labs and once you get hang of MVC then I will talk about why MVC but for now let me talk about what is MVC MVC stands for Model View Controller MVC is nothing but it's a architectural pattern where we divide our web application into 3 layers one is the controller the other one is the model and the last one is a view So in other words every layer in MVC is assigned a unique responsibility So the view is for look and feel and positioning So the view is the something the something the end user will actually see The model supplies data and business logic so the models are nothing but the classes like customer class you supplier class etc and the model can intract with data access layer or some kind of services like wcf service or web service which gives data and the controller who is actually the heart of MVC architecture he is nothing but he is a coordinator between model and the view so what happens is when a end users sends a request or action i will say rather so here when we say request in MVC we term it as a action so when a end users actually sends a action to MVC site it first hits the controller and the controller depending on the action picks up the appropriate model and binds it with the view and that result is send to the end user browser so for example if a user send a action like add customer now remember actions are normally verbs like add customer, update customer, go to home or whatever right so when a end user actually sends a actions like add customer this add customer action first comes to the controller The controller then says okay let me search you know which is appropriate model for it so must be the appropriate model is a customer model object so he create objects of a customer model object and ties up with a view probably called customer.aspx or in case you are using razor it can be customer.cshtml so with this approach you know we end up assigning unique responsibility to each layer so when we make changes in one layer the other layer is not affected and this makes the software project more