jonathanpeppers
jonathanpeppers

Reputation: 26505

C# - web service with aspx page

We are required to use a specific library for serialization, that is used like this:

var obj = Serializer.Deserialize(myStream); //Read
Serializer.Serialize(obj, myOtherStream); //Write

We need to expose this via a web service, and I have gotten this working as such:

And all of this seems to be working fine.

Is there a better way to handle this? We want our service to run in IIS, but we didn't know if there was any overhead in making this an aspx page.

Is there any benefit to hooking this up with WCF?

Upvotes: 3

Views: 682

Answers (1)

RQDQ
RQDQ

Reputation: 15579

Well, if you have a page that has no actual web form components, you can just use a handler page. That will cut down on some overhead.

<%@ 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;
        }
    }
}

Upvotes: 6

Related Questions