Start with this answer. I’ll start from her to continue.
The basic structure of an ASP.MET MVC Project
I created my project, I can connect it to a base of SQL Server Express, and I have something very similar to that:
- App_data: Directory that stores local databases such as Localdb;
- App_start: Classes invoked to start the application;
- Content: Files that are usually part of the presentation, such as images and style sheets (CSS);
- Controllers: Application controllers. Organize requests made to the system and harmonize data entities (Models);
- fonts: Font directory;
- Migrations: Directory that stores incremental database migrations. It is usually used with the Entity Framework, which is installed by default in the ASP.NET MVC project;
- Models: The description of the data entities and the relationships between them. Within a DDD concept, would be the domain of application;
- Scripts: Directory for presentation programming. Usually stores Javascript files;
- Views: Presentation layer directories and files. Not necessarily HTML, but by default, it is. Views are written using the notation Razor.
The "Hello, World" (or equivalent) in the MVC5
How I chose the option of ASP.NET Identity, 3 Controllers are created:
AccountController.cs
;
HomeController.cs
;
ManageController.cs
;
What is always created is the HomeController.cs
. He usually comes like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Teste.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
}
The method Index
would be the closest to a "Hello, World" that we can have. When starting the site, is the first request that the system meets. Try to run and put one breakpoint in the return View()
to confirm this.
Ciclo Básico
In the case of Index
, who has one instruction only:
public ActionResult Index()
{
return View();
}
We ask that one be returned View without giving anything to her. As we do not inform her name, the MVC will search in Views/Home
by a file called Index.cshtml
. If not, you will look for other extensions whose name begins with Index
and then you’ll look for Index
inside Views/Shared
.
In fact, it is in Views/Shared
that remains the layout system main, ready login screens and a standard screen of errors.
Note that the method returns a ActionResult
. ActionResult
can be many things:
- One View;
- A redirect to another Action;
- A file;
- An answer to raw requisition;
- A JSON;
- AN XML;
- etc., etc., etc..
I will not go into detail about this so as not to overstate the question.
Viewbag
Note that in the other methods we have the use of ViewBag
:
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
ViewBag
is an auxiliary dynamic object to fill the View with some useful information. Should not be used for persistent information. Excellent for messaging, useful identifiers and small controls. Never should be used for complex business rules.
And now?
We have several questions that can serve as next steps in your learning. We have the ASP.NET MVC website with its tutorials. The tag Asp.net-mvc has an internal Wiki with more information and material for study. Need more, can open a question or join the chat and take your question with us.
Your question is wide, try to make it more specific, stackoverflow works different from a forum can see the differences in tour see this one link has tips on how to elaborate a question and welcome the.
– rray
So Raniery. First access the official website of Asp.net mvc. This link has several tutorials on the technology, and from a basic to a little deeper. Another reference is the site of k19 and Caelum is also a reference source. But the purpose of Sopt is to help with codes made, look at these links, try and come back here to help in some error. =]
– Érik Thiago
The book "Programming with ASP.NET MVC" by Alfredo Lotar is very good for those who are starting, I’ve learned a lot. I’m not good, because I started reading a little while ago, but the book teaches the basic functions.
– user27693
Start with the basics: The correct name is
Asp.Net MVC
http://www.asp.net/mvc/overview/getting-started/introduction/getting-started– FernandoNomellini