ASP.NET MVC Hello World
To display your first MVC application, we need to create at least one page, so we are displaying here Hello world as it’s the first program in many languages. To create your first MVC Hello world, follow these steps :
Step 1
Go to Controller Folder, right click the folder > Select Add > and then Controller, displayed as:
Step 2
Name your Controller Home > and then click Ok. Displayed as:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace ExampleApplication.Controllers { public class HomeController : Controller { // // GET: /Home/ public ActionResult Index() { return View(); } } }
Step 3 (Adding Views)
Right Click Index function > select Add View
Name the view > Click Add
Step 4 (Adding Hello world Message)
Now your solution explorer will look like this :
Inside Index.cshtml include your message as:
@{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>Index</title> </head> <body> <div> Hello World </div> </body> </html>
Step 5 (Debug)
Press the F5 button and your debugging will start which display your Hello World message as: