Hello Guys,
Today We are gonna start with the Asp.Net Mvc development..
I Hope you people are also eager to learn it.....so let's begin with the work...
before starting with the development make sure that you have clear understanding of Asp.Net MVC basic and When to choose Asp.Net MVC ?
What You Should Know Before Developing an Asp.Net MVC Application
We make few assumptions about your technical background. We assume that you know the C# .NET programming language — all the code samples will be in c# also assume that you know basic HTML. ASP.NET MVC uses many advanced features of the C# .NET language.
What Software Do You Need?
You can download all the software that you need to build ASP.NET MVC applications from here. You need to install three software components:
1. Microsoft .NET Framework 3.5 Service Pack 1 The Microsoft .NET framework includes the Microsoft ASP.NET framework.
2. Microsoft ASP.NET MVC 1.0—The actual ASP.NET MVC framework that runs on top of the ASP.NET framework.
3. Microsoft Visual Web Developer 2008 Service Pack 1 or Microsoft Visual Studio
Understanding the Sample ASP. NET MVC Application
A good way to get a firmer grasp on the three logical parts of an MVC application is to take a look at the sample application that is created automatically when you create a new ASP.NET MVC project with Visual Studio.
Follow these steps :1. Launch Visual Studio.
2. Select the menu option File, New Project.
3. In the New Project dialog, select your programming language as C# and select the ASP.NET MVC Web Application template. Give your project the name MyFirstMvcApp and click the OK button.
Note : I am using VS 2010 so its having latest release of MVC that is MVC 2 that is why it is showing "ASP.NET MVC 2 Web Application" otherwise You will have simple "ASP.NET MVC Web Application" in VS 2008. Make sure that you select the .NET Framework 3.5 as the target framework.
4.Immediately after you click the OK button to create a new ASP.NET MVC project, you see the Create Unit Test Project dialog shown in the below snap.Leave the default option selected—Yes, Create a Unit Test Project—and click the OK button.
5. Visual Studio creates the default files for a new ASP.NET MVC project. After all the files are created, the Solution Explorer window should contain the files shown in the below image :
The Solution Explorer window in above Figure contains two separate projects: the ASP.NET MVC project and the Test project. The Test project contains all the unit tests for your application.
ASP.NET MVC Folder Conventions
The ASP.NET MVC framework emphasizes convention over configuration. There are standard locations for each type of file in an ASP.NET MVC project. The ASP.NET MVC application project contains the following folders:
- App_Data—Contains database files. For example, the App_Data folder might contain a local instance of a SQL Server Express database.
- Content—Contains static content such as images and Cascading Style Sheet files.
- Controllers—Contains ASP.NET MVC controller classes.
- Models—Contains ASP.NET MVC model classes.
- Scripts—Contains JavaScript files including the ASP.NET AJAX Library and jQuery.
- Views—Contains ASP.NET MVC views.
When building an ASP.NET MVC application, you should place controllers only in the Controllers folder, JavaScript scripts only in the Scripts folder, ASP.NET MVC views only in the Views folder, and so on. By following these conventions, your application is more easily maintained, and it can be more easily understood by others.
Running the Sample ASP.NET MVC Application
When you create a new ASP.NET MVC application, you get a simple sample application. You can run this sample application by selecting the menu option Debug, Start Debugging (or press the F5 key).
The first time that you run a new ASP.NET MVC application in Visual Studio, you receive a dialog asking if you want to enable debugging. Simply click the OK button.When you run the application, your browser opens with the page in Figure below :

This sample application is implemented with one ASP.NET MVC controller and two ASP.NET MVC views. The sample application does not contain any business or data access logic, so it does not contain any ASP.NET MVC model classes.
The controller is located in the Controllers folder:
\Controllers\HomeController.cs
If you open the HomeController in the Code Editor window, you will see the code as below :
Controllers\HomeController.cs

There are two methods named Index( ) and About() . Methods exposed by a controller are called actions. Both the Index() and About() actions return a view.
When you first run the sample application, the Index() action is invoked and this action returns the Index view. If you click the About tab, the About( ) action is invoked and this action returns the About view.
The two views can be found in the Views folder at the following location:
\Views\Home\About.aspx
\Views\Home\Index.aspx
The content of the Index view is contained as below :
Notice that a view consists mostly of standard HTML content. For example, the view contains standard <h2> and <p> tags. A view generates a page that is sent to the browser.
That's it...!!!
You learned how the ASP.NET MVC framework implements the Model View Controller pattern and how ASP.NET MVC enables you to perform pattern-based software development.
So ? how was the first ride to ASP.NET MVC Sample Application ?? :-) I Hope it would be great... :-)
Hope this helps...
No comments:
Post a Comment