我有一个页面布局具有下列asp.net的MVC不是渲染动作
_app.cshtml
<div id="top_right">
@{ Html.Partial("_LogOnPartial"); }
</div>
偏日志包含
_LogOnPartial.cshtml
@{
Layout = null;
}
@if (Request.IsAuthenticated)
{
Html.RenderAction("Details", "Account");
}
else
{
Html.RenderAction("LogOn", "Account");
}
个渲染操作方法IM期待看到是
AccountController.cs
public class Account
{
public PartialViewResult LogOn()
{
return PartialView();
}
}
将由帐户/登录时返回的登录局部视图是
LogOn.cshtml
@model Presentation.Models.LogOnModel
<div id="login">
@Html.ValidationSummary()
<h2>Start by Loggin in</h2>
@using (Html.BeginForm("LogOn", "Account"))
{
@Html.Hidden("returnUrl", Request.Url.PathAndQuery)
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>
<span class="bluey">Username:</span><br />
@Html.TextBoxFor(m => m.UserName, new {tabindex = "1", Class = "field"})
@Html.ValidationMessageFor(m => m.UserName, "*")
</td>
<td>
<span class="bluey">Password:</span><br />
@Html.TextBoxFor(m => m.Password, new {tabindex = "2", Class = "field"})
@Html.ValidationMessageFor(m => m.Password, "*")
</td>
</tr>
<tr>
<td>
<input name="login" type="submit" value="Submit" class="input_btn" tabindex="3" />
</td>
<td>@Html.CheckBoxFor(m => m.RememberMe) @Html.LabelFor(m => m.RememberMe) <span class="bluey"> | </span> @Html.ActionLink("Forgot Password?", "Password", "User")></td>
</tr>
</table>
}
</div>
我跟踪了流过,我可以看到它被击中廷
Html.RenderAction("LogOn", "Account")
,并从那里返回局部视图但是当我观看局部视图(LogOn.cshtml)的HTML的页面没有被渲染时,它甚至不是存在于该源。
我在这里错过了一些基本的东西,有没有更好的方法来实现这一目标?
所以我跟踪到它的方式我调用部分视图将其更改为@ Html.Partial似乎呈现正确,为什么另一个不显示内容的任何原因? – 2012-03-05 11:40:12