Search code examples
asp.netpagemethods

Consuming a "Page Method" from outside of the ASP.NET Page


I have a asp.net web app with some in page web service methods. It is not an asmx page, just Default.aspx. For example:

    [WebMethod]
    public static string SignUp(UserCredential userCredential)
    {
    }

I have no problem consuming this web service using jquery embeded in the Default.aspx page. Now I want to consume this web method in a console program for example. When I add the web reference to the console program, it said: The HTML document does not contain Web service discovery information.

How can I consume this in page web service?


Solution

  • You cannot consume that page method from outside of the page. You need a separate service for that.

    You should do the following:

    1. Create a separate WCF service project to hold the new service
    2. Extract the guts of your page method into a similar service method in your new service project
    3. Test the new service and make it work
    4. In your ASP.NET project, use "Add Service Reference" to permit you to reference the new service
    5. Call the new service from inside of the page method