Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are using C# 4, use default value for optional parameter</p> <pre><code>public ActionResult Organic(int id = 0)//Store/Organic { ProductManager mgr = new ProductManager(); var list = mgr.IsOrganic(id); return View(list); } </code></pre> <p>If C# 3 only, use DefaultValue attribute for optional parameter</p> <pre><code>public ActionResult Organic( [System.ComponentModel.DefaultValue(0)] int id) //Store/Organic { ProductManager mgr = new ProductManager(); var list = mgr.IsOrganic(id); return View(list); } </code></pre> <p>But I'm wondering why you are calling Organic method that way, that is with no parameter.</p> <p>If you want to test if the StoreController's Organic action is working, type this in url:</p> <p><a href="http://localhost/Store/Organic/7" rel="nofollow">http://localhost/Store/Organic/7</a></p> <p>or this:</p> <p><a href="http://localhost/Store/Organic?id=7" rel="nofollow">http://localhost/Store/Organic?id=7</a></p> <p>If you used custom name for the parameter id of your StoreController's Organic action, say organicId:</p> <pre><code>public ActionResult Organic(int organicId = 0) //Store/Organic?organicId=7 { ProductManager mgr = new ProductManager(); var list = mgr.IsOrganic(id); return View(list); } </code></pre> <p>,this url will not work: <a href="http://localhost/Store/Organic/7" rel="nofollow">http://localhost/Store/Organic/7</a></p> <p>,that will not have runtime error, but the organicId value won't be passed a value, and as such will always have a value of 0</p> <p>,you must use this instead: <a href="http://localhost/Store/Organic?organicId=7" rel="nofollow">http://localhost/Store/Organic?organicId=7</a></p> <p>By the way, where does the runtime error come from? Upon clicking a link? Try to hover on that link and look at your browser's status bar, yourl URL must conform to this: <a href="http://localhost/Store/Organic/7" rel="nofollow">http://localhost/Store/Organic/7</a> or this <a href="http://localhost/Store/Organic?id=7" rel="nofollow">http://localhost/Store/Organic?id=7</a>. </p> <p>If it doesn't look that way, change your ActionLink to this:</p> <p><code>@Html.ActionLink("Store", "Organic", new {id = 7})</code></p> <p>or if you are using plain HTML:</p> <pre><code>&lt;a href="Store/Organic/7"&gt; </code></pre> <p>Or this:</p> <pre><code>&lt;a href="Store/Organic?id=7"&gt; </code></pre>
    singulars
    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