Question

In the default ASP.NET MVC 5 web project, the "Login" view ("Login.cshtml") has a BeginForm call like this:

@using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))

I'm trying to convert all my ActionLink, BeginForm (etc.) calls to use T4MVC, and so I changed it to:

@using (Html.BeginForm(MVC.Account.Login().AddRouteValue("ReturnUrl", (string)ViewBag.ReturnUrl), FormMethod.Post, new { @class = "form-horizontal", role = "form" }))

...which worked fine.

However, there's another form in "ExternalLoginConfirmation.cshtml", which starts like this:

@using (Html.BeginForm("ExternalLoginConfirmation", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))

I tried to use the same approach:

@using (Html.BeginForm(MVC.Account.ExternalLoginConfirmation().AddRouteValue(...)

...but the object returned by MVC.Account.ExternalLoginConfirmation has no AddRouteValue method.

I think this is because ExternalLoginConfirmation is an async action method that actually returns a Task<T> rather than just a T.

Is there any way I can get this to work with T4MVC, or do I simply need to leave this one alone? (I know I can just replace the magic strings using MVC.Account.ActionNames.ExternalLoginConfirmation and MVC.Account.Name), but it would be nice to be able to use the helper.

Was it helpful?

Solution

This is covered in this thread. Basically, try:

MVC.Account.ExternalLoginConfirmation().Result.AddRouteValue(...)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top