Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li>create a new empty MVC 3 project, using Razor.</li> <li><p>add a class definition under Models folder, i.e:</p> <pre><code>namespace MvcApplication1.Models { public class WhateverNameYouWantModel { public string Foo { get; set; } public string Bar { get; set; } } } </code></pre></li> <li><p>right click on Controllers folder and add a new controller. the name must end with "Controller". don't bother checking option to add action methods. the controller would look like this:</p> <pre><code>using System.Web.Mvc; using MvcApplication1.Models; namespace MvcApplication1.Controllers { public class HelloController : Controller { public ActionResult Index() { return View(new WhateverNameYouWantModel()); } } } </code></pre></li> <li><p>right click on the Index() signature above and choose "Add View". Make sure nothing is checked, the view name matches the action name "Index" and Razor is the engine. add the model type at the top:</p> <pre><code>@model MvcApplication1.Models.WhateverNameYouWantModel @{ Layout = null; } &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Index&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt;hello world!&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre></li> <li><p>set the mvc project as your startup project, press F5, the browser will open to <a href="http://localhost:xxxx" rel="nofollow">http://localhost:xxxx</a> now you will need to point to <a href="http://localhost:xxxx/Hello/Index" rel="nofollow">http://localhost:xxxx/Hello/Index</a></p></li> </ol> <p>In asp.net mvc names are everything between the views, actions and controllers. Its all convention, you don't need to stick to it but if you don't you are gonna have to do some extra plumbing.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload