Web Service Works Local but not on WinHost.com

Discussion in 'Site Programming, Development and Design' started by droach99, Apr 24, 2011.

  1. Last edited by a moderator: Oct 14, 2015
  2. Bare Bones - Same Result

    I tried to simplify. I put out a one page Default.aspx. In includes a JQuery library reference. The AJAX call to the web service is in the subsequent script tag.

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title>Chicken Quiz</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />

    <script src="jquery-1.5.2.min.js" type="text/javascript"></script>

    <script type="text/javascript">
    $(document).ready(function() {
    url: "MyWebService.asmx/RiddleAnswer",
    dataType: "text",
    type: "POST",
    data: {},
    error: function(err) {
    alert("Error:" + err.toString());
    success: function(data) {
    $('#Answer').html("<h2>" + data + "<h2>");

    <form id="form1" runat="server">
    <h1>Web Service Test - Chicken Quiz</h1>
    <div id="TellMeMore">
    <p>Why did the chicken cross the road?</p>
    <p id="Answer">Answer???</p>

    When I run it locally in Visual Studio 2008, it works fine. Run it on Winhost and I get this response:

    Error:[object Object]​

    This is coming from the "alert("Error:" + err.toString());" statement in my error handling section.
    Here is the content of the MyWebService.asmx file that references the code behind file, MyWebService.cs:

    <%@ WebService Language="C#" CodeBehind="App_Code\MyWebService.cs" Class="MyWebService" %>

    Code Behind file: MyWebService.cs from the App_Code folder :
    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.Services;
    using System.Web.Script.Services;

    /// <summary>
    /// Summary description for MyWebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    public class MyWebService : System.Web.Services.WebService {

    public MyWebService () {

    //Uncomment the following line if using designed components

    public string RiddleAnswer() {
    return "She wanted to lay it on the line.";


    You can see this in action at http://www.livemission.org
    Last edited by a moderator: Oct 14, 2015
  3. Ray


    What do you get when you run it on your computer? Do you actually get the answer to the riddle question? Where is the answer being pulled from, off a database?
  4. Yes, Works Great in VS 2008

    Yes, it works great.

    In the code above, you can see the jQuery code call the web service method named RiddleAnswer:

    url: "MyWebService.asmx/RiddleAnswer",
    MyWebService.asmx's code behind file is App_Code\MyWebService.cs. It contains this code:

    public string RiddleAnswer() {
    return "She wanted to lay it on the line.";
    If I can find out what's wrong with this web service, I can fix the one I'm really interested in. I didn't want to waste anybody's time weeding through lots of code.

  5. Ray


    Are you sure you uploaded all the libraries/modules/assemblies in your applications bin folder? You mentioned that you use "JQuery library". This is not installed on the servers GAC. It maybe on yours.
  6. Hi droach99,

    Have find any solution to your problem? I'm experiencing the same problem now. I also use jQuery Ajax and asp.net web service. It perfectly working in my local if I use the Winhost database. But when I uploaded it in Winhost, my jQuery code is not working.

    Hi Ray,

    jQuery is a Javascript Library, do you think it has something to do on GAC?

    Last edited by a moderator: Oct 14, 2015
  7. Ray


    The library is not installed on the GAC so you definitely will need to upload it to your applications Bin folder.
  8. Did you ever figure this out.

    I'm running into the same problem performing an ajax call with $.ajax({...});

    Working locally and getting a 500 error when deployed.
  9. Figured this out needed to add this to the system.web section of web.config:

    <add name="HttpGet"/>
    <add name="HttpPost"/>
  10. Elshadriel

    Elshadriel Winhost Staff

    Thanks for posting the update. I'm sure others will appreciate it.

Share This Page