Click here to Skip to main content
15,888,205 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
This is my web service which i used to retrieve data from database (I used data set for it).It runs on IIS properly but when I upload it on web server it gives method error 500.
MSIL
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class ReceiptService : System.Web.Services.WebService
{
    public ReceiptService () {

        //Uncomment the following line if using designed components
        //InitializeComponent();
    }
    [WebMethod]
    public CascadingDropDownNameValue[] GetSchoolName(string knownCategoryValues, string category)
    {
        dsScoolTableAdapters.school_detailTableAdapter school_detailAdapter = new dsScoolTableAdapters.school_detailTableAdapter();
        dsScool.school_detailDataTable schools = school_detailAdapter.GetSchoolName();
        List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
        foreach (DataRow dr in schools)
        {
            string school_name = (string)dr["school_name"];
            string district = (string)dr["district"];
            values.Add(new CascadingDropDownNameValue(school_name, school_name.ToString()));
        }
        return values.ToArray();
    }


}
Posted
Updated 2-Aug-16 23:58pm

The 500 Internal Server Error is a "server-side" error, meaning the problem is not with your PC or Internet connection but instead is a problem with the web site's server.

Read about Error 500 here: HTTP Error 500 Internal server error[^]

Also this microsoft article: How Web site administrators can troubleshoot an "HTTP 500 - Internal Server Error"[^]
 
Share this answer
 
Comments
vineesha 25-May-11 8:36am    
No I am not asking about HTTP Error 500 Internal server error, on my page method error 500 occurs if you had any solution for it then tell me. my page link is - http://vidyabhartimahakoshal.org/sspstore/Ghosh.aspx
In case anyone is as dumb as I apparently am for me the issue was that I left out
[System.Web.Script.Services.ScriptService]

in my web service declaration! D'oh! Hopefully this will save someone the time I spent trying to track down the issue.
 
Share this answer
 
In case this problem occurres with the large amount of data try change value in the parameter
maxJsonLength
in the web.config:
XML
<system.web.extensions>
        <scripting>
            <webServices>
                <jsonSerialization maxJsonLength="5000000" />
            </webServices>
        </scripting>
    </system.web.extensions>


this solution was found in http://forums.asp.net/t/1038620.aspx/2/10[^]
 
Share this answer
 
I get the solution of that error.In this i used dataset for data binding but on the web server it is not work perfectly then now i changed the code as
using System;
using System.Collections;
using System.Configuration;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using AjaxControlToolkit;
using System.Data;
using System.Data.SqlClient;
/// <summary>
/// Summary description for ReceiptService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class ReceiptService : System.Web.Services.WebService
{
string connStr = ConfigurationManager.ConnectionStrings["TutTestConn"].ToString();
public ReceiptService () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public CascadingDropDownNameValue[] GetSchoolName(string knownCategoryValues, string category)
{
//dsScoolTableAdapters.school_detailTableAdapter school_detailAdapter = new dsScoolTableAdapters.school_detailTableAdapter();
//dsScool.school_detailDataTable schools = school_detailAdapter.GetSchoolName();
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
SqlCommand dCmd = new SqlCommand("LoadAllSchool", conn);
dCmd.CommandType = CommandType.StoredProcedure;
SqlDataReader rdr = null;
rdr = dCmd.ExecuteReader();
List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
while(rdr.Read())
{
string school_name = (string)rdr["school_name"];
string district = (string)rdr["district"];
values.Add(new CascadingDropDownNameValue(school_name, school_name.ToString()));
}
return values.ToArray();
}

}
 
Share this answer
 
I also got this kind of error and after done research on Internet, I found solution.

If the below line of code is commented, first remove the comment and then try to execute, it will work. If you will not find, then type it.

[System.Web.Script.Services.ScriptService()]

It should be like this in WebService

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class CascadingDropDown : System.Web.Services.WebService {


It should fix the error
 
Share this answer
 
In case anyone is as dumb as I apparently am for me the issue was that I left out
[System.Web.Script.Services.ScriptService]

in my web service declaration! D'oh! Hopefully this will save someone the time I spent trying to track down the issue.
 
Share this answer
 
Comments
Devesh2179 20-Oct-13 5:29am    
Thanks it works
Install this add-on on server

http://www.microsoft.com/en-us/download/details.aspx?id=883[^]
 
Share this answer
 
Comments
VICK 25-Jul-14 1:07am    
What could be the logic to answer an already solved and 3 year old question???
XML
<system.web.extensions>
        <scripting>
            <webServices>
                <jsonSerialization maxJsonLength="5000000" />
            </webServices>
        </scripting>
    </system.web.extensions>
 
Share this answer
 

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