using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace TestBackend.Controllers
{
public class HomeController : Controller
{
public ActionResult LogIn()
{
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login(User u)
{
if (ModelState.IsValid)
{
using(MyDatabaseEntities dc = new MyDatabaseEntities())
{
var v= dc.Users.Where(a=>a.UserName.Equal(u.UserName)&& (a=>a.Password.Equal(u.Password)).firstordefault());
if (v!=null)
{
Session["LogedUserName"]=v.UserName.ToString();
return RedirectToAction("AfterLogIn");
}
}
}
return View(u);
}
public ActionResult AfterLogIn()
{
return View();
}
}
}
可访问性不一致:参数类型' TestBackend.Controllers.User'比方法更不易访问' TestBackend.Controllers.HomeController.Login(TestBackend.Controllers.User)'
我是C#mvc用户的新手 我无法理解为什么参数类型不易访问