{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "denglu", action = "Index", id = UrlParameter.Optional }
);
}
namespace diyige.Controllers
{
public class dengluController : Controller
{
//
// GET: /denglu/
public ActionResult Index()
{
return View("denglu");
}
public ActionResult denglu() {
string ssss = "asdasd";
//获取页面的数据
SysAdmin objAdmin = new SysAdmin()
{
LoginId = Convert.ToInt32(Request.Params["loginid"]),
LoginPwd = Request.Params["loginPwd"].ToString()
};
//调用业务逻辑层
objAdmin = new SysAdminManger().AdminLogin(objAdmin);
if (objAdmin != null)
{
ViewData["info"] = "欢迎您:" + objAdmin.LoginId;
}
return View();
}
}
}
# 这里是视图的代码
<body>
<div>
<form action="/denglu/denglu" method="post" >
用户名:<input type="text" name="loginid" />
密码:<input type="text" name="loginPwd" />
<input type="button" value="登录" />
</form>
<%=ViewData["info"] %>
</div>
</body>
视图的代码放在Views下的denglu下的denglu.aspx了么
还有,你是post上去的,前面应该加上
[HttpPost]
注意你denglu()这个方法返回类型,如果是View(),就要有对应的视图存在。
谢谢一楼和二楼的回答, 但问题应该不是出在这两个方面,