I'd like to create a form that posts data to specific action in my SurfaceController But Html.BeginUmbracoForm creates a form that has action set to link to current View
For example, I need form to post data to LoginUserPost action and I get a LoginView by LoginUserGet action Html.BeginUmbracoForm creates a form on a page with action set to LoginUserGet url. Why could this happen?
using (Html.BeginUmbracoForm<Controllers.MemberLoginSurfaceController>("MemberLoginPost", FormMethod.Post, new { action = this.Url.Action("MemberLoginPost", "MemberLoginSurface") }))
This controller causes "Can only use UmbracoPageResult in the context of an Http POST when using a SurfaceController form" exception, when I try to return CurrentUmbracoPage()
Troubles using Html.BeginUmbracoForm
I'd like to create a form that posts data to specific action in my SurfaceController
But Html.BeginUmbracoForm creates a form that has action set to link to current View
For example, I need form to post data to LoginUserPost action and I get a LoginView by LoginUserGet action
Html.BeginUmbracoForm creates a form on a page with action set to LoginUserGet url. Why could this happen?
I have a View:
using (Html.BeginUmbracoForm<Controllers.MemberLoginSurfaceController>("MemberLoginPost", FormMethod.Post, new { action = this.Url.Action("MemberLoginPost", "MemberLoginSurface") }))
{
<div id="wrapper">
<div class="form-auth" style="width:420px; height:195px; overflow:hidden;">
<a class="close" onclick="clearForm()"></a>
<div class="text" style="margin-left:0px;">
Вход для участников</div>
<ul class="auth">
<li>
<label>
E-mail</label>
@Html.TextBoxFor(x => x.Username)
@Html.ValidationMessageFor(x => x.Username)
</li>
<li>
<label>
Пароль</label>
<span class="input-block">
@Html.PasswordFor(x => x.Password)
@Html.ValidationMessageFor(x => x.Password)
</span><a href="javascript:window.parent.showGeneralIFramePopup('/usercontrols/ForgotPassword.aspx', false, null);" class="remind">Забыли?</a> </li>
</ul>
<div class="remember">
@Html.CheckBoxFor(x => x.RememberMe)
<label>
Запомнить</label>
</div>
<div class="submit">
@*<asp:Button ID="usLoginButton" runat="server" Text="Войти" CommandName="Login" ValidationGroup="vgLoginUser" />*@
<input type="submit" id="usLoginButton" value="Войти"/>
<span>или</span> <a href="javascript:window.parent.showGeneralIFramePopup('/usercontrols/RegisterWays.aspx', false, null);" onclick="window.parent._gaq.push(['_trackEvent', 'registerMainForm', 'registration']);">Зарегистрироваться</a>
</div>
</div>
</div>
}
And a SurfaceController with such action:
[HttpPost]
[ActionName("MemberLoginPost")]
public ActionResult MemberLoginPost(MemberLoginModel model)
{
if (ModelState.IsValid && !MembersManager.IsMemberSponsor(model.Username))
{
result = MembersManager.AuthenticateUser(model.Username, model.Password);
if (result.IsAuthenticated)
{
model.Username = MembersManager.GetActualLoginString(model.Username);
FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);
return RedirectToUmbracoPage(32684);
}
else
{
return CurrentUmbracoPage();
}
}
else
{
return CurrentUmbracoPage();
}
}
This controller causes "Can only use UmbracoPageResult in the context of an Http POST when using a SurfaceController form" exception, when I try to return CurrentUmbracoPage()
is working on a reply...