【发布时间】:2016-09-27 18:50:08
【问题描述】:
我正在创建一个网络应用程序,我想在按钮单击时重定向页面,我使用所有文本框和按钮作为输入字段我在互联网上看不到太多关于此的内容,如何在按钮单击时重定向到另一个页面(如果验证了 ID 和密码)
例如,我在模态中执行了所有与 sql 相关的查询,并且我从模态 (if true(redirect to login page))(if false(redirect to signup page)) 传递真或假我需要在我的控制器上做什么
[HttpPost]
public ActionResult testlogin(string username, string password)
{
// called my modal here and creates its object(modal m=new modal();)
//what to do now
}
在我的模式中,我有类似的 sql 查询
`sql command cmd=new sqlcommand("select * from empdet where empid='"+user+"' and pass='"+password+"'",con);
con.open();
SqlDataAdapter da=new SqlDataAdapter(cmd);
dataset ds=new dataset();
da.fill(ds);
if(ds.tables[0].rows.count>0)
{
bool true;
}
else
{
bool false;
}
con.close();
bool = Convert.ToBoolean(cmd.ExecuteReader());
return user;`
如果bool返回true,页面应该重定向到欢迎页面,否则重定向到登录页面
【问题讨论】:
-
@WillRay 先生编辑了我的问题
标签: asp.net-mvc