asp.net mvc - .Net MVC : unable to get ViewBag value in View -


as beginner doing simple example understand basic razor concepts , when set values using viewbag in controller class , try them in view not printed , neither shows insentience nor error , please hep me . doing

mode class : product

public class product     {         public int productid      { get; set; }         public string name        { get; set; }         public string description { get; set; }         public decimal price      { get; set; }         public string catagoery   { get; set; }     } 

homecontroller (pasting specific method not working me )

   public actionresult myproduct()          {             viewbag.productcount = 1;              viewbag.productquality = "good";               return view(product);           } 

productview

@model razorapplication.models.product  @{     viewbag.title = "demo";     layout = "~/views/_basiclayout.cshtml"; }  <table>         <tr>             <td>name</td><td>@model.name</td>          </tr>         <tr>             <td>quality</td><td>@viewbag.productcount</td>          </tr>          <tr>             <td>quality</td><td>@viewbag.productquality</td>          </tr>      </table> 

your code looks fine, setting values in viewbag in action, should printed in page, try ctrl + f5 refresh page, may page loading browser's cache,by pressing ctrl + f5 page rendered fresh server.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -