मैं this एक स्व-होस्टेड webservice (मूल रूप से डब्लूसीएफ वेबएपी में लिखा गया) का उदाहरण देना चाहता था, लेकिन नए एएसपी.नेट वेबएपीआई (जो डब्ल्यूसीएफ वेबएपी के वंशज हैं) का उपयोग करना चाहता था।एएसपी.नेट वेबएपीआई में एचटीपीएस सर्विसहोस्ट के बराबर क्या है?
using System;
using System.Net.Http;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using Microsoft.ApplicationServer.Http;
namespace SampleApi {
class Program {
static void Main(string[] args) {
var host = new HttpServiceHost(typeof (ApiService), "http://localhost:9000");
host.Open();
Console.WriteLine("Browse to http://localhost:9000");
Console.Read();
}
}
[ServiceContract]
public class ApiService {
[WebGet(UriTemplate = "")]
public HttpResponseMessage GetHome() {
return new HttpResponseMessage() {
Content = new StringContent("Welcome Home", Encoding.UTF8, "text/plain")
};
}
}
}
हालांकि, या तो मुझे सही पैकेज नहीं मिला है, या HttpServiceHost AWOL है। (मैंने 'स्वयं होस्टिंग' संस्करण चुना है)।
मुझे क्या याद आ रही है?
[यह] (http://code.msdn.microsoft.com/ASPNET-Web-API- स्वयं- होस्ट-30abca12/view/Reviews) ने मुझे कुछ काम करने में मदद की है, लेकिन ऐसा नहीं लगता है एक सख्त समकक्ष। – Benjol