API Controls API Controls - 1 year ago 143
C# Question

how to redirect a page from web service and return the value of textbox c#

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);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
// want to redirect to welcome page if condition satisfied.
//want to show the label error message(declare as string errormsg)

This is my webservice it will validate role(user will select from dropdownlist), username(textbox) and password(textbox) if all the validation completed the page should be redirected to welcome page and if information provided by user is not correct, label should be visible on

login page And i cant return the values of the textbox, this is the error when i return something(return keyword must not be followed by object expression)

Answer Source

Return value from this methord getuserinfo(string username, string password, string role, string errormsg) get it to your action method from action method you can redirect user to another page using

 RedirectToAction("Welcomepage", "Account");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download