[英]subscribing to an asynchronous web-service event in both winform and aspx page (C#)
[英]C# - web service with aspx page
我們需要使用特定的庫進行序列化,使用如下:
var obj = Serializer.Deserialize(myStream); //Read
Serializer.Serialize(obj, myOtherStream); //Write
我們需要通過Web服務公開它,我已經得到了這樣的工作:
所有這一切似乎都很好。
有沒有更好的方法來處理這個? 我們希望我們的服務在IIS中運行,但我們不知道是否有任何開銷使這個aspx頁面。
使用WCF連接它有什么好處嗎?
好吧,如果你有一個沒有實際Web表單組件的頁面,你可以使用一個處理程序頁面 。 這將減少一些開銷。
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/xml";
Serializer.Serialize(obj, context.Response.Stream); //Write
}
public bool IsReusable {
get {
return false;
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.