Lets say I have _Layout.cshtml where I have this:
@if (ViewBag.SignUpURL == null)
{
<a href="@Url.Content("~/Home/Join")" ><span>
<strong>JOIN NOW!</strong></span></a>
}
else
{
<a href="@ViewBag.SignUpURL" ><span>
<strong>JOIN NOW!</strong></span></a>
}
When I try to populate ViewBag.SignUpURL under
public ActionResult Index()
{
ViewBag.SignUpURL = HttpContext.Request.Url.AbsoluteUri.Replace("Index", "SignUp");
return View();
}
Index view uses _Layout.cshtml.
And nothing happens…
In general I need somehow pass data to Layout page from page that uses it.
Is it possible to do?
THANK YOU!!!
UPDATE:

You should consider using Html.RenderAction() which will then go back to controller action that you specify, and you’ll be able to return a partial view with a model for it:
View:
Controller action