Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET Web服务:身份验证失败。例外类型";:&引用;“系统无效操作例外”;_C#_Asp.net_Ajax_Web Services_Autocomplete - Fatal编程技术网

C# ASP.NET Web服务:身份验证失败。例外类型";:&引用;“系统无效操作例外”;

C# ASP.NET Web服务:身份验证失败。例外类型";:&引用;“系统无效操作例外”;,c#,asp.net,ajax,web-services,autocomplete,C#,Asp.net,Ajax,Web Services,Autocomplete,我的网页中有一个文本框和Ajax AutoCompleteXtender。我在本地开发计算机上没有问题。当我将此网页上载到远程主机时,收到“身份验证失败。异常类型”:“System.InvalidOperationException”此错误 这是我的密码 <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> <Services>

我的网页中有一个文本框和Ajax AutoCompleteXtender。我在本地开发计算机上没有问题。当我将此网页上载到远程主机时,收到“身份验证失败。异常类型”:“System.InvalidOperationException”此错误

这是我的密码

 <form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
    <Services>
        <asp:ServiceReference Path="~/WebService.asmx" />
    </Services>
</asp:ScriptManager>
<div>
    <asp:TextBox ID="txtAra" runat="server"></asp:TextBox>
    <cc1:autocompleteextender id="AutoCompleteExtender1" runat="server" servicepath="~/WebService.asmx"
        servicemethod="IsmeGoreGetir" minimumprefixlength="1" targetcontrolid="txtAra"
      >
                    </cc1:autocompleteextender>
</div>
</form>
  • 哇,我真的希望你不要把它上传到面向公众的服务器上。在几秒钟内就拥有了那个网站。prefixText:=“1=1;从Rehber删除*;--”是它的一个非常简单的版本

  • 由于您有字段,我只能假设您在一个连接上有多个读卡器。你在躲野战博士

    • 由于是这种情况,因此每次调用都会分配一个新连接,从而导致内存泄漏
    • 既然是这种情况,你刚刚创造了很多比赛条件访问字段con

    • cmd也一样

  • dr[“AD”].ToString()可以抛出null ref,或者在db模式与代码失去联系时抛出null ref


所以,如果你修正了你的比赛条件和有趣的代码,它可能真的会起作用。另外,下次提供stacktrace.:)

直接从IE中的客户端调用IE中的网页WebService.asmx。首先检查WebService在托管到生产机器后是否可访问

如果有用的话。检查当客户端从代码调用服务时需要何种身份验证

此问题与连接或命令无关。它与Web服务身份验证有关


参考

你真的应该把con和cmd变量包装在一个using(或try/finally)blockEasy中的“crap code”注释中。并不是这里的每个人都是主程序员这不是我的问题的解决办法,但你对我的编码问题是正确的。
OleDbConnection con;
OleDbCommand cmd;
OleDbDataReader dr;


[WebMethod(EnableSession = true)]
public string[] IsmeGoreGetir(string prefixText, int count)
{
    con = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("~/App_Data/nobetRehber.mdb"));

    cmd = new OleDbCommand( "Select * from Rehber Where AD like '" + prefixText.ToUpper() + "%'",con);

    OleDbDataAdapter da = new OleDbDataAdapter(cmd);
    if (con.State != ConnectionState.Open)
        con.Open();

    DataTable dt = new DataTable();
    da.Fill(dt);
    string[] items = new string[dt.Rows.Count];
    int i = 0;
    foreach (DataRow dr in dt.Rows)
    {
        items.SetValue(dr["AD"].ToString(), i);
        i++;
    }
    con.Close();
    return items;
}