Click here to Skip to main content
15,352,974 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have need to add Login view on Master page. i add it using partial view.

public ActionResult Login()
           return PartialView();

       public ActionResult Login(login response)
           string uname = response.uname;
           string pwd = response.pwd;
           login l = new login();
           int i = l.loginuser(uname, pwd);
           if (i > 0)
               return RedirectToAction("Index", "Admin");
               return View();


when it post back then it show error: Child actions are not allowed to perform redirect actions.

Please help me for solve that Problem

Thanx with Regards
Zoltán Zörgő 21-Sep-13 2:52am
This is quite normal. Since there can be many partial views rendered on a page, it would be a mess if several redirects would be issued. Share your view also. You can render partial.
AnkushSharma100 21-Sep-13 3:00am
On my master page:
<%= Html.Action("Login","Home") %>

and on Login Partial page

<%using (Html.BeginForm("Index","Admin"))
{ %>
<td style="width:100%; text-align:center;">
<table style="width:92%; text-align:left; margin-left:auto; margin-right:auto;" border="0" cellspacing="1" cellpadding="2" >
<tr><td style="width:100%;">Username or Email <br />

<%= Html.TextBoxFor(m => m.uname, new {id="b1", @class="LoginTextBox"})%>
<tr><td style="width:100%;">Password <br />

<%= Html.PasswordFor(m => m.pwd, new { @class = "LoginTextBox" })%>
<input type="image" name="Login" title="Login" class="Masterlogin" src="../../Content/images/login.jpg" style="height:25px;width:85px;border-width:0px;" />
<tr><td class="remember-me">
<span title="Uncheck if using shared computer."><input id="ctl00_CYBEX_LOGIN_Remember_Me" type="checkbox" name="ctl00$CYBEX_LOGIN$Remember_Me" checked="checked" /><label for="ctl00_CYBEX_LOGIN_Remember_Me">Remember Me</label></span>
<tr><td class="forgotPassword">
» Register Now
<tr><td class="forgotPassword">
» Forgot Password ?
<% }%>
Kush kant dayal 25-Jun-14 9:41am
Following is your Controller action method:
public ActionResult ShowPartialViewUsingCode()
RechargeMobileViewModel objModel = new RechargeMobileViewModel();
objModel.ListAllMonthsName = objModel.getAllDataforTextFile();
return PartialView("_RechargeMobileView.cshtml", objModel);

Following is your code snippet for rendering partial view in your view

MvcVariousApplication.Models.RechargeMobileViewModel objModel = new MvcVariousApplication.Models.RechargeMobileViewModel();
Html.RenderPartial("~/Views/Shared/_rechargemobileview.cshtml", objModel);

1 solution

Please choose a different name for the partial view like _Login and then try to redirect . You can't perform redirect action over Partial View . PartialView nothing but some resusable portion of a html.
Hope this helps
AnkushSharma100 21-Sep-13 6:04am
i m changed the name of partial view but same error will generate...
Jameel VM 21-Sep-13 8:20am
in which action you are try to redirect and when?
AnkushSharma100 22-Sep-13 5:01am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900