带有C#、Ajax和Jquery的Web服务不能与ASP.Net一起使用

带有C#、Ajax和Jquery的Web服务不能与ASP.Net一起使用,c#,javascript,jquery,web-services,C#,Javascript,Jquery,Web Services,我在C#中创建了一个WebService。其中我有一个方法: 我在每个页面上使用相同的方法创建了一个AndroidWebservices.asmx和一个Default.aspx [System.Web.Services.WebMethod] public bool CheckLogin(string email, string password) { //Get the User Information DB.User cur_user = DB.User.ByEmail(em

我在C#中创建了一个
WebService
。其中我有一个方法:
我在每个页面上使用相同的方法创建了一个
AndroidWebservices.asmx
和一个
Default.aspx

[System.Web.Services.WebMethod]
public bool CheckLogin(string email, string password)
{
    //Get the User Information
    DB.User cur_user = DB.User.ByEmail(email.Trim());

    if (cur_user.CheckPassword(password)) {
       return true;
    } else {
       return false;
    }
}
对于我放入的Default.asxp页面

对于AndroidWebService.asmx,我没有注释
[System.Web.Script.Services.ScriptService]


正在运行此服务的
http://localhost:49524/
以及我公司的.com域名

我在tomcat服务器上创建了一个新目录:

http://  localhost:8080/
此代码是一个简单的表

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="user-scalable=no, width=device-width" />
    <link rel="stylesheet" type="text/css" href="css/iphone.css">
    <link rel="stylesheet" 
        href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
    <script src="js/iphone.js"></script>
    <title></title>
</head>
<body>
    <div id="container">
        <div id="header">
            <h1><a></a></h1>
            <div class="loginContainer">
                <table cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                        <td valign="top" style="width:100px">
                            <div class="rounded-end">email</div>
                        </td>
                        <td valign="top">
                            <input type="text" id="email" class="login" />
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" style="width:100px">
                            <div class="rounded-end">password</div>
                        </td>
                        <td valign="top">
                            <input type="password" id="password" 
                                class="login" />
                        </td>
                    </tr>
                </table>
                <input type="button" class="loginButton" value="login" 
                    onclick="loginCheck(); return false;"/>
            </div>      
        </div>
    </div>
</body>
</html>
我尝试过的事情:

dataType: "json"
不返回任何内容

dataType: "jsonp"
返回页面。。i、 e

"<!doctype><html> ...... "
“…”
每当我运行
Default.aspx
作为我的url时,函数就会返回页面的html/文本,我可以将代码加上+querystring放在url中,然后返回页面。。但没有数据 它似乎并没有调用该方法,而只是返回页面。。如上所述。。 我所要做的是返回true或false,以确保用户登录到下一页


我非常感谢人们的评论,我不得不回到办公室再做一次。当我得到一个有效的答案时,我会立即标记一个被接受的答案。

我想这是因为您将您的方法标记为受保护。将其标记为public,然后重试

所以

变成

public bool CheckLogin(string email, string password)

我使用了一个
$.jsonp插件
,它让ajax调用变得更容易
我还必须在我的网络配置中添加以下内容:

<webServices>
  <protocols>
    <add name="HttpGet"/>
    <add name="HttpPost"/>
  </protocols>
</webServices>


我也会在控制台打开的情况下运行,所以我知道当我遇到相同的原始错误时,看起来你在
if
块中没有返回任何内容。这是一个输入错误,我返回的是真还是假请更新代码:)请告诉我你没有检查客户端的登录状态?!这并没有修复错误,但我做了更改,因为您是对的,它需要公开,而不是保护。。但我仍然将html作为响应,而不是布尔值。
public bool CheckLogin(string email, string password)
<webServices>
  <protocols>
    <add name="HttpGet"/>
    <add name="HttpPost"/>
  </protocols>
</webServices>