To access that data in a master page, your controllers would need to add it to the ViewData so the master page has access to it.
public ActionResults Index(string id)
{
ViewData["SearchID"] = id;
return View();
}
Then in your master page, you can access it in the ViewData
using (Html.BeginForm("Search", "Bing", { id = ViewData["SearchID"] })
For a strongly-typed View, I have a BaseModel class that has properties that the master page needs and all my other models inherit the base class. Something like this...
public class BaseModel
{
prop string SearchID {get;set;}
}
public class HomeIndexModel : BaseModel
{
}
public ActionResults Index(string id)
{
HomeIndexModel model = new HomeIndexModel();
model.SearchID = id;
return View(model);
}
Your master page would look like this:
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage<BaseModel>" %>
<% using(Html.BeginForm<BingController>(action => action.Search(Model.SearchID))) { %>