Reputation: 185
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?
Upvotes: 0
Views: 1077
Reputation: 34846
Another option you have is to use the ASP.NET Web API to create your service methods and then consume them in a console application, like this:
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
class Program
{
static void Main(string[] args)
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:9000/");
// Add an Accept header for JSON format.
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
// Call Web API methods here
}
}
Read Calling a Web API From a .NET Client for a tutorial on consuming an ASP.NET Web API service from a C# console application.
Upvotes: 1
Reputation: 161773
You cannot consume that page method from outside of the page. You need a separate service for that.
You should do the following:
Upvotes: 0