asp.net应用程序中的登录页面 [英] login page in asp.net application

查看:89
本文介绍了asp.net应用程序中的登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,

我为登录页面创建了一个Web方法,这是我的代码

Dear Sir,

I create a web method for login page this is my code

[WebMethod]
    public bool Login(string user , string pass)
    {
       pass ="TxtPassword.Text";
        user ="TxtUserName.Text";
        string username = "Login";
  string   Password = "Login";
        if (user == username && pass == Password)
        {
            return true;
        }
        else
        {
            return false;
        }

    }
}



但这不起作用.

请给我解决方法
在此先感谢.

Arvind kumar singh



But this not working.

Please give me solution
Thanks in Advance.

Arvind kumar singh

推荐答案

删除引号并使用它.
Remove the quotes and use this.
pass = TxtPassword.Text;
user = TxtUserName.Text;


必须将WebMethod标记为静态":


A WebMethod must be marked as ''Static'':


[WebMethod]
public static bool Login(string user , string pass)
{
    pass ="TxtPassword.Text";
    user ="TxtUserName.Text";
    string username = "Login";
    string Password = "Login";
    if (user == username && pass == Password)
    {
        return true;
    }
    else
    {
        return false;
    }
}


别忘了您应该使用

Don''t forget that you should be using

return (user.Equals(userName) && pass.Equals(Password));


而不是

return (user == username && pass == Password);


这篇关于asp.net应用程序中的登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆