Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are using the wrong overload for the <code>View()</code> method. Here's what you're using when you call <code>View(testFirst, testSecond)</code>:</p> <pre><code>protected internal ViewResult View( string viewName, string masterName ) </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/dd470743.aspx" rel="nofollow">MSDN Reference</a>.</p> <p>By putting "test" for the <code>viewName</code>, you're telling the Controller to render a View called <code>Test</code> (test.cshtml). Which you don't have.</p> <p>It sounds to me like you are trying to correlate WebForms with MVC. It is not the same, and you are seeing a prime example with routing. ASP.NET MVC doesn't work off of the NTFS structure (folders and files). It relies on routing through route definitions.</p> <p>If you are looking to render the View "RouteTest", then do something like this:</p> <pre><code>public ActionResult RouteTest(string testFirst, string testSecond) { ViewBag.testFirst = testFirst; ViewBag.testSecond = testSecond; return View(); } </code></pre> <p>This will render the "RouteTest" view and in your dynamic object <code>ViewBag</code> you will have access to two properties: <code>testFirst</code> and <code>testSecond</code>. In your view you can pull those values. (Although I highly recommend strongly-typed Views using a ViewModel)</p> <h2>Example Solution</h2> <p><strong>ViewModel</strong></p> <pre><code>public class TestData { public string testFirst { get ; set ; } public string testSecond { get ; set ; } } </code></pre> <p><strong>Controller</strong></p> <pre><code>public ActionResult RouteTest(string testFirst, string testSecond) { TestData td = new TestData(); td.testFirst = testFirst; td.testSecond = testSecond; return View(td); } </code></pre> <p><strong>Strongly-Typed View</strong></p> <pre><code>@model TestData @Html.Label(Model.testFirst) @Html.Label(Model.testSecond) </code></pre>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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