I currently am writing a web app that needs to pass some configuration settings from a settings page to a page page with a search box.
Currently I’m passing the config data from the settings page to the home page with:
public ActionResult Settings(Configuration configuration)
{
return RedirectToAction("ConfigSet", "Home", configuration);
}
And in the home controller:
public ActionResult ConfigSet(Configuration configuration)
{
return View("Index");
}
I’m generating a partial view with:
public PartialViewResult Search(string q)
{
List<Stuff> results = this.Search(q);
return PartialView("SearchResults", results);
}
With the partial view rendered like so:
@using (Ajax.BeginForm("Search", "Home", new AjaxOptions {
HttpMethod = "GET",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "searchResults",
}))
{
<input type="text" name="searchString" />
<input type="submit" value="Search" />
}
My question is how would i pass the configuration settings to the partial view? I’ve been thinking about this for a couple of days and am really confused about it.
You can create a viewModel which will store your configuration setting like this
& in your action return MyViewModel
if you again want to pass configuration to controller then