如何从web服务重定向页面并返回文本框的值
本文关键字:返回 文本 web 服务 重定向 | 更新日期: 2023-09-27 18:08:40
public void getuserinfo(string username, string password, string role, string errormsg)
{
SqlConnection con = new SqlConnection(connectionstring);
List<object> logininfo = new List<object>();
if(role=="Admin" || role=="Super Admin")
{
SqlCommand cmd = new SqlCommand("select * from [admin] where userid='" + username + "' and password ='" + password + "'", con);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if(dt.Rows.Count>0)
{
// want to redirect to welcome page if condition satisfied.
}
else
{
//want to show the label error message(declare as string errormsg)
}
}
}
这是我的webservice,它将验证角色(用户将从下拉列表中选择),用户名(文本框)和密码(文本框),如果所有验证完成,页面应该重定向到欢迎页面,如果用户提供的信息不正确,标签应该在
上可见我不能返回文本框的值,这是当我返回一些东西时的错误(返回关键字不能后跟对象表达式)
返回getuserinfo(string username, string password, string role, string errormsg)
方法的值从action方法得到它你可以使用
RedirectToAction("Welcomepage", "Account");