I'm trying to get into a controller , get a parameter and print it in the View by a ViewData
or ViewBag
.
My Controller:
public ActionResult Index(string information)
{
ViewData["Bag"] = information;
return View();
}
My View:
@ViewData["Bag"]
The problem is that the information
parameter is null every time I step in the URL call for example: http://localhost/Home/Index/teste
.
routes.MapRoute( name:"Default1", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
This is the default route.