• Register
Welcome to Kodlogs Q&A, where you can ask programming questions and receive answers from other members of the community. For programmers, by programmers Kodlogs is an open community for anyone that does coding. We help you get answers to your toughest coding questions, share knowledge with your coworkers in private, and find your next IT dream job.

Most popular tags

java program php python javascript c# android r c spring-boot arrays html mysql entity-framework sql-server matlab redirect code program numpy spring asp loop net class quirks-mode internet-explorer-9 internet-explorer machine-learning winforms visual-studio-2010 webpack python-3 python-2 aspnet dataframe pandas jdbc ios eclipse sum loops css cmd tcp math security jquery sockets sql 7 number firebase-authentication aws-organizations amazon-web-services php-7 string-formatting cplusplus visual-studio-2015 net-core net-mvc msbuild extension-methods foreign-keys sql-server-2005 windows-services react-redux reactjs inputstream facebook-graph-api for-loop entity-framework-4 reportingservices-2005 reporting-services mips linear-regression scikit-learn anova deep-learning keras block-device melt reshape2 floating-point webpack-dev-server javascrip 0-lollipop android-5 statsmodels avx indentation-error eclipseide javafx-2 php-not-recognized laravel command-line unit-testing tinyurl atom-editor android-emulator android-studio android-sdk-tools ionic2 cordova jupyter-notebook foobar2k tcplistener net-2 net-4 ole-db-provider windows-10 vagrantfile ggplot2 glmnet jvm-arguments global-variables orm virtualenv atom xls oledb redux webclient prediction headless hyperlink outlook pipeline iis perfect-square objective-c carthage xcode8 compiler-errors numpy-ndarray standard-deviation xampp apple mdf destructor vagrant gettime gmail ioexception heuristics milliseconds reporting cpu npm modx-revolution goldsky modx prevnext javascript-dictionary stack-smashing device-monitor radio-button android-actionbaractivity android-activity android-fragments java-long unqualified-id ora-12154 javc c++ java nullpointerexception runtime-error drjava awt-eventqueue dsx math-pow ajquery nosuchelementexception appcompatactivity jtextfield jpanel inputmismatchexception deque jupyter javafx lvalue junit tensorflow ibm factorial servlet apache boot virtualbox indentation jvm margins 2147483647 xcode firebase plot deployment processor automation socketexception pointers concatenation oracle devices color recursion sequence search date caching expected response directory csv algorithms release collections facebook float figure url expression microsoft sorting sort datetime httpwebrequest cryptography json ajax exe dictionary required windows string variable size dll system exception files x int function random import code 2
0 votes
6 views
Describing ASP.NET MVC 5  with Model,  view and controller ?
by (290 points)  
reshown by

1 Answer

0 votes
Hello everyone and welcome to Learn MVC step by step in 2 days 2 days means 16 hoursyes you guessed it right 16 hoursso first thing you would ask me that some kind of scammer somethingabsolutely not this is not scam something this is the real thingso next thing you would ask me that hmmm so is it really possible to learn MVC in 16 hoursmy answer is yes absolutely yes and confidentially yesokaySo before we start MVC rightwe need to go and arrange our environment we need to go and ensure that we have the tools with usthe first thing what we should have with us is the ultimate edition so this complete tutorialthis complete MVC tutorial is in MVC 5 but it holds too for MVC 4 as well it holds too forMVC 3 as wellor MVC 2 also down the line rightSo first thing is we need to go and get hold of this ultimate edition here you can seeI 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 downloadso once you go and search Visual Studio Ultimate edition on google rightyou 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 pageSo now the next thing you would be asking me is thatwhy 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 editionThis tutorial sincerely very very sincerely aims at making you a true MVC professionalSo I don't want to lose some features by downloading  XPlus edition rightAnd second thing you know if worried about the price watch on that screen watch my screen over thereit 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 rightso here you have 90 days before you a Visual Studioand 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 rightSo 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 hereSo click on file here click on new project and click on this web menu over hereSo once you click on the web menu here you can see a template here saying ASP.NET Web ApplicationYou 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 4if we click on this web you are not seeing anything rightSo 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 okayNow in case you want to do MVC 4 then you need to click on Visual Studio 2012and you need to use this template over hereand 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 5In 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 thingsvery quickly before I move ahead with difference between MVC 4 and MVC 5I want to clarify here something regarding ASP.NETregarding MVC and regarding Web formLot of people think that ASP.NET is different and MVC is different  Absolutely wrong okayFirst thing our base framework is .NET rightFrom .NET ASP.NET is created so again ASP.NET is a framework for web applications okayFrom .NET we have various framework you know likewe have a windows frameworkyou know we have a web framework So this ASP.NET is a web frameworkand using ASP.NET microsoft has created web forms and it has created MVCSo don't think that MVC is different from ASP.NETMVC 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 formswhenever 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 formsand 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 2013In 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 sayokay now i want to create MVC now i want to create web form now i want to create API whatever it is rightSo 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  rightSo i am going to go and start from this template over hereif you wish in case you are into visual studio 2012you can start from here the steps are almost same okaybut 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 okayNow you can see as i have said that it is one ASP.NET frameworkyou know all of these guys Web forms  and MVC they have emerge from the ASP.NET frameworkSo you can see now this second template here is telling me so what you want to dodo you want to use web forms do you want to do coding in MVCdo you want to do coding in Web APISo from here you can see now you can go and make a choice of what things you want in your projectSo at this moment we are learning MVC So we have to go and select MVC over hereso you can see MVC is checked over there that is rightand 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 momentwe 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 rightSo 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 hereso you can see you know the new project is created you can also see the solution of the new projectIn case you are not seeing the solution click on view here and click on solution explorerSo there you can see the complete solution of your MVC projectso 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 MVCFor 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 okayso 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 MVCbut for now let me talk about what is MVC MVC stands for Model View ControllerMVC is nothing but it's a architectural pattern where we divide our web application into 3 layersone is the controller the other one is the model and the last one is a viewSo in other words every layer in MVC is assigned a unique responsibilitySo 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 logicso the models are nothing but the classes like customer class you supplier class etcand the model can intract with data access layer or some kind of services like wcf service or web service which gives dataand the controller who is actually the heart of MVC architecture he is nothing but he is a coordinator between model and the viewso 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 controllerand 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 customerthis add customer action first comes to the controllerThe 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 objectso 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 layerso when we make changes in one layer the other layer is not affected and this makes the software project more maintainable and more better in terms of architectureso let us map our MVC architecture with the solution which we have just opened so you can see here we have the controllers folder here  so all your controller code will go inside this folder you can see we have a models folder here all your customer class your supplier class or whatever is your domain objects they will go into this and then we have the views folder which will have the aspx or html or must be the cshtml UI rightso at this moment don't worry about other folders I will come to them as we go ahead in the labsso at this moment this where the controllers will gothis is where the models code will go and this is where the views code will goso let us move ahead and let's do lab1 Now before we start with Lab 1 let's go ahead and delete all these codes you know which have been inserted by the MVC templates so that we can learn from scratch so you can see that I have deleted all the codes currently which is there in the controller folder I want to go and delete all the folders which are there in my view folder so that we can start from scratch and I can teach you to exactly how things work So you can see now all the codes have been deleted from the controllers folderI have deleted the models folder did not have any code and even from the views folder there is no code here as well rightso everything clean everything nice in the view folder there are some files but leave that files at this moment you knowthey wont't affect us you know while we are this first labSo let us start with lap 1displaying a simple
by  
...