I'm trying to centralize some of the common Web User Controls used in all of
our web applications (like header, footer) and put them in a web service to
be called by all the other web applications. There are a couple of ways I
can think of that can probably accomplish what I need. I'm most interested
in rendering the control on the WS server end, and then stream the result to
the consuming clients (the other web applications). I think this is
definitely doable but just can't quite figure how this should work. The
following is what I have so far on the WS server end in the asmx class:
[WebMethod]
public void GetPageHeader() {
/*oad the user control */
UserControl uc = new UserControl();
UserControl header =
(UserControl)uc.LoadControl(@"~\UI\HeaderNoMenu.as cx");
/*render the user control into the HttpResponse stream */
TextWriter tw = new
StreamWriter(this.Context.Response.OutputStream);
HtmlTextWriter htw = new HtmlTextWriter(tw);
header.RenderControl(htw);
}
This compiles ok and runs without error when invoked from a browse (it
doesn't show anything in the browser as expected). However, I'm not sure
how to get the stream from the client end as no stream is exposed anywhere.
A fragment of the proxy class generated is shown below.
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="CommonUIElementsSoap",
Namespace="http://tempuri.org/")]
public class CommonUIElements :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://tempuri.o
rg/GetPageHeader", RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
public void GetPageHeader() {
this.Invoke("GetPageHeader", new object[0]);
}
Do I need to implement something myself in order to get the stream, like
maybe using SoapExtension class? Any suggestions would be helpful.