Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
tell me how to use web service in login page and make successful login with response
Posted
Comments
Mukesh Ghosh 3-Nov-14 6:30am    
What you have tried till now?
Member 11191738 3-Nov-14 6:39am    
i call the web service in code bt i don't understand when user login then this username and password how to authenticate in service when username & password are right thus login is successful
ZurdoDev 3-Nov-14 7:59am    
1. Reply to comment so user is notified instead of adding a new comment to your own question.
2. Post the relevant code.
3. Be clear about where you are stuck.
Member 11191738 3-Nov-14 9:37am    
Not getting response when i am login

Hi,

May be your expectation Match this,

I m Using WebSerive

AdminService.asmx

My Weservice Code

VB
[WebService(Namespace = "http://tempuri.org/")]
   [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
   [System.ComponentModel.ToolboxItem(false)]
   // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    [System.Web.Script.Services.ScriptService]
   public class AdminService: System.Web.Services.WebService
   {
        [WebMethod]
        public string DoLogin(string UserName,string Password)
        {
           //Your Login checking Logic
DataTable resFromDB = DBContext.GetDataTable("select * from tblUSer where UserName = "+UserName+" && Password = "+Password+");
 string resString = "";
            if (resFromDB.Rows.count >0 )
            {
               
                if(resFromDB.Rows[0]["UserType"]=="Admin")
                   resString = "Admin_1_"+resFromDB.Rows[0]["UserID"].toString();
                else
                   resString = "User_1_"+resFromDB.Rows[0]["UserID"].toString();

            }
            else
            {
                 resString = "Error_2_0";
            }
            return resString;
        }
   }


And Webserivce Calling Code will be


protected void btnProcess_Click(object sender, EventArgs e)
        {
            
            AdminService ServiceObj = new AdminService();
string res = ServiceObj.DoLogin(txtUserName.Text, txtPassword.Text);
string successPart = res.split("_")[1];
            if (successPart  == 1)
            {
                //Login Success Logic
                if(res.split("_")[0]=="Admin")
                   Response.Redirect("AdminHome.aspx");
                else
                   Response.Redirect("EmployeeHome.aspx");
            }
            else
            {
                //Login Fail Logic
                Response.Redirect("Error.aspx");
            }
        }


Note : If Webservice External then, need to Add Webservice as Reference

Thank you !
Siva Rm K
 
Share this answer
 
v2
Comments
Member 11191738 3-Nov-14 8:40am    
thanks
Member 11191738 3-Nov-14 8:49am    
how can separate user LIKE ADMIN, USER ,RESELLER ????
rmksiva 4-Nov-14 0:58am    
if you want diffrent user means pass another argument from UI to Webserive or if you use common db for all users means ! alter the return code of webservice (with some Logic). Like if(username in admin List) then return "Admin_1" (Reseller means) "Res_1" login fail ("Fail_2")

Always check 2nd part of of return string for Result
Member 11191738 4-Nov-14 1:18am    
sorry plz send me code i don't understand
Member 11191738 4-Nov-14 1:37am    
void btnLogin_Click(object sender, EventArgs e)
{
Infiysms.servicelist.InfySMS abc = new Infiysms.servicelist.InfySMS();
string str= abc.UserLogin(txtLogin.Text.Trim(), txtpassword.Text.Trim());



i get the string bt i dont ubderstand how to get response like invalid user /username password incorrect etc
You should do these:

1. Store the different type of user as you have mentioned while adding in the database.
2. Then check the condition if its admin then redirect to a page you want only admin to see.
3. Do these for other to types of user.
 
Share this answer
 
Comments
Member 11191738 3-Nov-14 9:34am    
i am not use database to store this all details are save in .txt file (dictionary) so plz help me how to solve this
Amit Jangid 3-Nov-14 12:59pm    
Than you can your file to do the same. Retrieve the details from there and check the condition.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900