I\'m trying to build an Href using Razor The string is going to end up looking like this:
https://www.notmysite/controller/action?order_ID=xxxxxxx&hashComparator
I've figured out a way of doing it:
@{
var url = string.Format(
"https://www.notmysite.co.uk/controller/action?order_ID={0}&hashComparator={1}",
@Uri.EscapeDataString(Model.bookingNumber.ToString()),
@Uri.EscapeDataString(Model.hashCode));
}
Edit 2015 - As mentioned by Jerads post - The solution is to only encode the query string elements and not the whole URL - which is what the above does.