To create a simple structure for an ASP.NET MVC site
The simplest for a Hello World.
Some folders are mandatory, such as Controllers, Models and Views folders.
I’m using Visual Studio 2013 Express for Web.
Create a new ASP.Net Web Application project:
Add basic MVC references (libraries, Global.asax, Routeconfig, etc.)
As a result, you will have a very basic Solution. One that if you run F5, will not display any page, because there are no pages, but there is the application Asp.NET. See how the structure looks:
No views, no controls, no script folder (where we usually have javascript files) and no image folder, ie no files "unnecessary".
To create a Hello World with a View
Now just create a new Controller :
I use the MVC 5 Controller - Empty
See that a controller was created, which I called Defaultcontroller, very simple:
Now we have a Controller with an action called Index, but we still need to create a view for this Action. To do this, just right-click on the Action Index and choose Add View. Fill the screen below:
As a result you have a cshtml file that is the view of the Controller Defaultcontroller’s Index action.
Now just start debug, F5, and you’ll see a beautiful blank page.
To include Hello World, simply write in the HTML file Index.cshtml the word Hello World.
If I don’t even want to create a View for my Hello World
If you don’t even want to have a View file, you can choose to do a Hello World as Laerte demonstrated in its reply:
public string HelloWorld()
{
return "Hello World";
}
So just start the application and navigate to http://localhost:<suaPorta>/Default/HelloWorld
You could add in the question what procedure you used in VS to create this project?
– bfavaretto