c# - How do I return an image from a ServiceStack query? -
i've got solution works, although suspect there more efficient way this... end result photo of subject displayed on web page. that, have servicestack service returns byte array, feed httphandler takes byte array , turns image. way can set src of image http://www.mydomain.com/httphandler.ascx?id , image of specific person displayed. hoping bypass httphandler , use servicestack return image web page. can't find examples of this, believe read possible servicestack. possible?
the docs on service return types shows how return image responses, techniques used in servicestack's imgur.servicestack.net demo.
an alternative solution industrial strength webserver nginx serve static file instead, avoiding servicestack, asp.net or managed .net code, can writing static file , redirecting it.
this how can configure nginx serve static files in /img/
, add cache headers static files have common web formats file extensions (ico|pdf|flv|swf|exe|txt|css):
server { listen 0.0.0.0:80; server_name myserver.net; root /home/src/myserver.net; location /img/ { alias /home/src/myserver.net/img/; } location ~* \.(ico|pdf|flv|swf|exe|txt|css) { add_header cache-control public; add_header cache-control must-revalidate; expires 1d; } location / { index index.html index.htm index.aspx default.htm default.aspx; fastcgi_pass 127.0.0.1:9000; fastcgi_param script_filename $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } }
Comments
Post a Comment