Using MVC 3 Razor, how can I specify a variable within a call to @Url.Content().
Example:
@{
var myVar = Request.QueryString["foo"];
}
<a href="@Url.Content("~/bar?@myvar")">click here</a>
You're already in the c# context at that point, so you can use the variable just like you would in a code file. Try this:
<a href="@Url.Content("~/bar?" + myvar)">click here</a>
string.Format. Or better yet, create a UrlHelper extension that accepts the variable in the method and bubbles up to Url.Content. But looking at your example, perhaps Html.ActionLink is a better option, then you can pass in the variable as route params.