Passing a param to the controller is null.. from examples ive seen im using correct overload. Any help much appriceated
@{ foreach (string str in ViewBag.ServerNames) { <ul> <img src="../../Content/Images/my_computer.png" alt="Computer Name"/> <li >@Html.ActionLink(linkText: str.ToString(),actionName: "Index",controllerName:"Customer", routeValues:new{str = str.ToString()} , htmlAttributes: null)</li> </ul> } }
public ActionResult Index(string conName) { Response.Write("con name = " + conName); Response.End(); string con = ConfigurationManager.ConnectionStrings[conName].ConnectionString; trakman_Entities db = new trakman_Entities(con); return View(db.customers.ToList()); } browser source code
<ul> <img src="../../Content/Images/my_computer.png" alt="Computer Name"/> <li ><a href="/Customer/Index/DefaultConnection">DefaultConnection</a></li> </ul> <ul> <img src="../../Content/Images/my_computer.png" alt="Computer Name"/> <li ><a href="/Customer/Index/trakman_Entities">trakman_Entities</a></li> </ul> <ul> <img src="../../Content/Images/my_computer.png" alt="Computer Name"/> <li ><a href="/Customer/Index/trakman_Entities1">trakman_Entities1</a></li> </ul>