Asp.net mvc 关于部分观点的另一个问题
我觉得自己像个十足的白痴,但我一辈子都不知道自己到底错过了什么 我有以下资料:Asp.net mvc 关于部分观点的另一个问题,asp.net-mvc,asp.net-mvc-3,c#-4.0,Asp.net Mvc,Asp.net Mvc 3,C# 4.0,我觉得自己像个十足的白痴,但我一辈子都不知道自己到底错过了什么 我有以下资料: @section TopPane { @*@{Html.Action(“_openidSignaturenPartial”,“Account”);}*@ @{Html.RenderAction(“_openidSignnPartial”,“Account”);} 使用您的mysite.com帐户登录或注册帐户 @{Html.RenderPartial(“_LoginPartial”);} @{Html.Rende
@section TopPane
{
@*@{Html.Action(“_openidSignaturenPartial”,“Account”);}*@
@{Html.RenderAction(“_openidSignnPartial”,“Account”);}
使用您的mysite.com帐户登录或注册帐户
@{Html.RenderPartial(“_LoginPartial”);}
@{Html.RenderPartial(“_RegisterPartial”);}
}
如您所见,我有3个局部视图正在渲染。
现在是控制器代码----
当我从OpenIdSignIn ActionResult()重新调用视图时,我得到以下错误
传递到字典中的模型项的类型为“Web.ViewModels.AccountIndexViewModel”,但此字典需要类型为“Web.ViewModels.AccountSignInViewModel”的模型项。
好的,很好,那么我将返回AccountSignInViewModel,对吗??然后我得到一个错误,说它需要AccountIndexViewModel。。。这里是第22个问题。您正在向主视图返回一个
AccountIndexViewModel
。这意味着这两个部分必须强类型化为AccountIndexViewModel
:
@model AccountSignInViewModel
- _对数的
- _注册方
\u openidsignital
而言,您是通过\u openidsignital
操作来渲染它的
return PartialView("_OpenIdSignInPartial");
根据错误消息,它看起来像是将\u openidSigningnPartial.cshtml
强键入到AccountSignInViewModel
:
@model AccountSignInViewModel
因此,请确保在返回局部视图时正在传递此模型的实例:
AccountSignInViewModel signInViewModel = ...
return PartialView("_OpenIdSignInPartial", signInViewModel);
您正在向主视图返回一个
AccountIndexViewModel
。这意味着这两个部分必须强类型化为AccountIndexViewModel
:
@model AccountSignInViewModel
- _对数的
- _注册方
\u openidsignital
而言,您是通过\u openidsignital
操作来渲染它的
return PartialView("_OpenIdSignInPartial");
根据错误消息,它看起来像是将\u openidSigningnPartial.cshtml
强键入到AccountSignInViewModel
:
@model AccountSignInViewModel
因此,请确保在返回局部视图时正在传递此模型的实例:
AccountSignInViewModel signInViewModel = ...
return PartialView("_OpenIdSignInPartial", signInViewModel);
亲爱的,让我试试,马上回来。谢谢你,达林,很好,先生。你太棒了。甜心,让我试试,马上回来。谢谢你,达林,很好,先生。你太棒了。