This was my original code:
@Url.Action("LoginYoutube", "Account", new { returnUrl = Request.QueryString["ReturnUrl"] }, "http")
Which would generate: http://localhost:2543/Account/LoginYoutube
With T4MVC I do:
Url.Action(MVC.Account.LoginYoutube().AddRouteValue("returnUrl", Request.QueryString["ReturnUrl"]))
and that generates: /Account/LoginYoutube
I need the last parameter with "http" in order to get the http://localhost:2543. The problem is with T4MVC I can only put 1 parameter for the call to Url.Action().
How can I get this to work?
T4MVC is indeed missing something here, but it should be easy to add. Please try the following. In T4MVC.tt, change:
public static string Action(this UrlHelper urlHelper, ActionResult result) {
return urlHelper.RouteUrl(result.GetRouteValueDictionary());
}
to
public static string Action(this UrlHelper urlHelper, ActionResult result, string protocol = null, string hostName = null) {
return urlHelper.RouteUrl(null, result.GetRouteValueDictionary(), protocol, hostName);
}
This should allow you to write:
@Url.Action(MVC.Account.LoginYoutube().AddRouteValue("returnUrl", Request.QueryString["ReturnUrl"]), "http")
Please let me know how that works, so we can decide whether to change this in the official template.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With