Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6901691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:42:18+00:00 2026-05-27T07:42:18+00:00

So I am pulling my hair out over this. Environment: ASP.net web form C#

  • 0

So I am pulling my hair out over this. Environment: ASP.net web form C# 2008.
I already have this solution in place.
I created an asmx webservice like the following (see code) and I am trying to access it via the browser. Basically when I point to http://localhost/service.asmx it works fine and I can see the available operations and stuff.. I can also see operation in detail at the url http://localhost/service.asmx?op=MethodName but the problem comes when I actually try the service or invoke. I get http://localhost/service.asmx/MethodName is not found.
Any idea what could be going wrong?

[WebService(Namespace = "http://locahost/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class WellnessService : System.Web.Services.WebService
{

    [WebMethod]
    public string MethodName()
    {
        return ViewManager.RenderView("~/Modules/CouponsPromotions/CouponCenter.ascx");
    }
}
public class ViewManager
{
    public static string RenderView(string path)
    {
        return RenderView(path, null);
    }

    public static string RenderView(string path, object data)
    {
        Page pageHolder = new Page();
        UserControl viewControl = (UserControl)pageHolder.LoadControl(path);

        if (data != null)
        {
            Type viewControlType = viewControl.GetType();
            FieldInfo field = viewControlType.GetField("Data");

            if (field != null)
            {
                field.SetValue(viewControl, data);
            }
            else
            {
                throw new Exception("View file: " + path + " does not have a public Data property");
            }
        }

        pageHolder.Controls.Add(viewControl);

        StringWriter output = new StringWriter();
        HttpContext.Current.Server.Execute(pageHolder, output, false);

        return output.ToString();
    }
}

This is how I am calling via JS

$(document).ready(function() {
$('#liCoupons').click(function() {
        $.ajax({
            type: "POST",
            url: "/services.asmx/MethodName",
            data: "", 
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                $('#result').html(msg.d);
            },
            error: ajaxFailed
            //error

        });
    });

    function ajaxFailed(xmlRequest) {
        alert(xmlRequest.status + ' \n\r ' +
              xmlRequest.statusText + '\n\r' +
              xmlRequest.responseText);
    }
});  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:42:19+00:00Added an answer on May 27, 2026 at 7:42 am

    I just copy pasted your partial code, added a web user control(only has static HTML “hello world”) of my own and tested the webservice and it works fine.

    couple of things to check.

    1) Debug and Step through code to see if web service is running all server code properly without any exceptions

    2) there is a Invoke button in http://localhost/service.asmx?op=Coupons part. test if it works correctly. if yes i think the problem lies somewhere else

    3) Also please review the error and its stacktrace to get a better idea. Post the stacktrace here with full error also in question.

    hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Pulling my hair out over this one. I have one wordpress install at /2009
I'm on the verge of pulling my hair out over this. Here I have
been pulling my hair out over this for the past few hours. i have
I'm pulling my hair out over this. I have this bit of javascript that
I'm pulling my hair out over this one. I have an app that when
I literally have been pulling my hair out over this for a few days
I have been having this problem and been pulling my hair out over it.
I have been pulling my hair out about this since Friday and I am
Ok I am pulling my hair out over this, There is no help on
I just spent a few hours pulling my hair out over this. I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.