我的viewmodel在不同的项目(类库)中。我添加了参考。但是当我从@model Fancy.Management.Model.Home.IndexModel的mvc4视图中调用它时。视图无法识别它。什么是我不知道的问题。 我的观点是如下图所示:查看无法识别我的视图模型
@model Fancy.Management.Model.Home.IndexModel
<html>
<head>
<title>Giriş</title>
</head>
<body>
@Html.BeginForm(){
<table>
<tr>
<td>Kullanıcı Adı:</td>
<td>@Html.TextBoxFor(m=>m.UserName)</td>
</tr>
<tr>
<td>Şifre:</td>
<td>@Html.PasswordFor(m=>m.Password)</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Giriş" /></td>
</tr>
</table>
}
</body>
</html>
我控制器如下图所示:
而且我的模型如下图所示:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Fancy.Management.Model.Home
{
public class IndexModel
{
public string UserName { get; set; }
public string Password { get; set; }
}
}
我们也不知道。请向我们展示您的视图/ viewmodel /控制器 – Thousand
我将我的代码添加到了问题中。 – fuat
究竟是什么问题?我发现你可以使用@ Html.PasswordFor(m => m.Password) td,这样看起来像你可以访问你的viewmodel的属性? – Thousand