网络服务错误500内部错误asp.net [英] webservice error 500 Internal Error asp.net
本文介绍了网络服务错误500内部错误asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在文档准备好函数中的JQuery中编写了一个Web服务调用,但未调用该函数
I have written a webservice call in JQuery in document ready function but its not calling the function
下面是代码 jQuery
Below is the code JQuery
`<script type="text/javascript">
$( document ).ready(function() {
var section = "Table - TLI (STOCK)";
$.ajax({
type: "GET",contentType: "application/json; charset=utf-8",
url: "pgWebService.aspx/SliderBlock",
dataType: "json",
data: "{'section':'" + section + "'}",
success: function (res) {
//$("#Text1").val(res.text);
console.log(res);
alert("DONE");
}
});
});
</script>`
C#代码 pgWebService
C# Code pgWebService
public static string SliderBlock(string section)
{
string html = "<ul class='maketabs listing-table search-filter change-view'>";
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["TLI"].ConnectionString);
SqlCommand cmd = new SqlCommand();
cn.Open();
cmd.Connection = cn;
cmd.CommandText = "Select * from CategoryDetails where section=" + section;
SqlDataReader rs = cmd.ExecuteReader();
while (rs.Read())
{
html="<li>"+rs.getValue(0).toString()+"</li>";
}
rs.Close();
cmd.Dispose();
cn.Close();
html = html + "</ul>";
return html;
}
推荐答案
如果您的方法SliderBlock
在后面的代码中,则使方法WebMethod
被ajax调用.此外,您还需要使其成为static
和要被GET
调用,您需要在WebMethod上enable GET
请求.
If your method SliderBlock
is in code behind than make your method WebMethod
to be called by ajax.Also you need to make it static
and to be called by GET
you need to enable GET
requests on your WebMethod.
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod(UseHttpGet = true)]
public static string SliderBlock(string section)
{
//Your code here
}
这篇关于网络服务错误500内部错误asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文