tags:

views:

290

answers:

2

I know that WCF is supposed to be transport agnostic, but is there a method to write directly to the client (web client esp.)?

I need to do the equivalent of response.redirect(url) and though it might be possible to just write out a "301 Location Moved" header.

I am trying to write a service that would move static content to a CDN (S3 or similar) on the first request and then redirect when complete. Then all subsequent requests would immediately redirect.

Any feedback would be greatly appreciated.

H

A: 

I do this in JavaScript on the client. Return a url to redirect to, then call Window.Location with the new url.

Chris Brandsma
I am actually trying to do something like <img src="http://www.mydomain.com/myservice.svc?url=encoded_original_url" /> - so I won't have access to the DOM to do a window.location. Thanks for the comment though. I guess I could try to work an image preload solution in javascript or something.
Hal
A: 

It should probably not be up to the service to tell the client where it's endpoint is (i.e. redirect the client like a web page might). You could set it up where the client knows about one endpoint for "create" and one endpoint for "get" (or whatever the subsequent calls are). Or you could just have your service decide "okay, this is not a create call, so I will go to the backend store (S3 or whatever) and get the data the client wants and hand it back to him." Personally, I prefer to hide complexity in the service rather than have an unnecessarily complex client, so I would probably go with the second approach.

JP Alioto
Yeah - thinking about the archetecture - it would make more sense to wrap the service in an HttpHandler or other pipeline aware location and call into the service from there. <img src="http://mydomain.com/statichandler.aspx?url=encoded" /> - then the statichandler.aspx calls into the service. Accepted.
Hal