我有一個運行輪廓的Umbraco 7 MVC網站。頁面上有兩個輪廓表單,運行順暢,沒有錯誤。我創建使用表面控制器登錄形式和現在,當任何輪廓的形式提交它得到的錯誤如下:輪廓和Html.Action崩潰「無法從兒童行動重定向」
Server Error in '/' Application.
Cannot redirect from a Child Action
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Cannot redirect from a Child Action
Source Error:
Line 404:
Line 405: <div class="lg-details">
Line 406: @Html.Action("MemberLogin", "MemberLoginSurface")
正如你可以看到我打電話使用@ Html.Action()地面控制器。任何幫助解決這個問題將不勝感激。
編輯 控制器代碼被用來
public class MemberLoginModel
{
[Required]
public string Username { get; set; }
[Required]
public string Password { get; set; }
public bool RememberMe { get; set; }
}
public class MemberLoginSurfaceController : Umbraco.Web.Mvc.SurfaceController
{
[HttpGet]
[ActionName("MemberLogin")]
public ActionResult MemberLoginGet()
{
return PartialView("MemberLogin", new MemberLoginModel());
}
[HttpGet]
public ActionResult MemberLogout()
{
Session.Clear();
FormsAuthentication.SignOut();
return Redirect("/");
}
[HttpPost]
[ActionName("MemberLogin")]
public ActionResult MemberLoginPost(MemberLoginModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.Username, model.Password))
{
FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return Redirect("/extranet/");
}
else
{
return Redirect("/extranet/");
}
}
else
{
TempData["Status"] = "Invalid username or password";
return RedirectToCurrentUmbracoPage();
}
}
TempData["Status"] = "Invalid request";
return RedirectToCurrentUmbracoPage();
}
}
調用使用
@Umbraco.RenderMacro("umbracoContour.RazorRenderForm", new { FormGuid = "a6362c56-a7d7-41dd-b4c9-61ea28d420f6" })
由於 馬克西
顯示更多代碼。控制器代碼 – Vishal
@Farzi更新了問題以顯示代碼以及我如何稱爲輪廓形式。謝謝 –