我在不同项目(类库)中的视图模型。我添加了参考。但是当我从我的 mvc4 视图中调用它时,比如@model Fancy.Management.Model.Home.IndexModel。查看不认识它。我不知道是什么问题。我的视图如下所示:
@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>
我的控制器如下图所示:
namespace Fancy.Web.Management.Controllers
{
#region Using Directives
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
#endregion
public class HomeController : Controller
{
#region Get
public ActionResult Index()
{
return View();
}
#endregion
}
}
我的模型如下所示:
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; }
}
}