asp.net-mvc - ASP.Net MVC3 渲染部分操作返回错误

标签 asp.net-mvc asp.net-mvc-3 razor

尝试在布局上呈现部分操作时遇到问题。上线:

@{Html.RenderAction("Login");}

我收到错误“CS1501:方法 'Write' 没有重载需要 0 个参数”。我也尝试过直接调用 RenderPartial,结果相同...你能告诉我哪里出了问题吗?

我的部分 View 的代码:

@model SikWebRole.Models.LogOnModel
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('.LoginLink').click(function () {
            $('#loginForm').submit();
        });
    });
</script>
@using (Html.BeginForm("LogOn", "Account", FormMethod.Post, new { id = "loginForm" }))
{
<div class="loginBox">
    <div class="errorMsg">
        @Html.ValidationSummary(true, "Błędny login/hasło.")
    </div>
    <div class="loginHolder">
        <input type="text" class="textInput" name="UserName" value="Login" />
    </div>

    <div class="passwordHolder">
        <input type="text" class="textInput" name="Password" value="Hasło" />
    </div>
    <input name="RememberMe" style="display:none;" type="hidden" value="true"/>
    <a href="#" class="loginLink" ><span class="loginButton">Zaloguj</span></a>

    <ul><a href="#"><li class="registerLi">Zarejestruj</li></a><a href="#"><li class="RemindLi">Przypomnij hasło</li></a></ul>
</div>

}

用于渲染 Action 的函数:

public PartialViewResult Login()
    {
        return PartialView("LogOnForm", new SikWebRole.Models.LogOnModel());
    }

我要渲染的部分 View 属于“LogOn”方法,它来自Account Controller,而Login方法在Picture Controller中,也许是这个原因?

我会很高兴所有的答案。

最好的问候

根据要求,这是我的 Layout.cshtml 的代码:http://pastebin.com/He2Rp5P4

最佳答案

在您的 cshtml 文件中使用 @Html.Partial,而不是 @Html.RenderPartial。

关于asp.net-mvc - ASP.Net MVC3 渲染部分操作返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8094857/

相关文章:

c# - RouteValueDictionary 到 HtmlAttributes

css - 如何将类添加到 @Html.ActionLink?

javascript - RequireJS 减慢了我的网络应用程序的加载速度

c# - 在 Entity Framework 中使用数学函数和 mysql

asp.net - 使用 Jquery Mobile 和 ASP.NET MVC 3 Razor 下载文件

asp.net-mvc-3 - 如何从 Orchard 中删除高级菜单模块?

c# - 如何在自定义帮助程序中使用 Html.BeginForm?

c# - asp.net MVC 创建我自己的路由

c# - 将 ASP.NET MVC 应用程序发布到 Web 主机 - 在 VS 项目结构而不是应用程序中部署文件

asp.net-mvc - 将 MVC2 Helpers 移至 MVC3 razor View 引擎