MVC 4 - Razor - Pass a variable into a href url
asp.net, asp.net-mvc, c#, razor
Solution
Like this:
<a href='@string.Format("http://myurltest.com/{0}/go/5/true", check1)'>
The point is to insert the whole URL into the markup, rather than combining markup and code parts.
Problem
How can I pass a variable into a url? What I try is this but this is not working. The url only shows this: `http://myurltest.com` and not the full path ``` @if(check1 != "d") { <li> <div class="a"></div> </li> <li> <div class="b"></div> </li> <li> <a href="http://myurltest.com/" + @check1 + "/go/5/true"> <div class="c"></div> </a> </li> } ```