Serving a static file with servicestack

99封情书 提交于 2019-12-10 06:13:43

问题


How would i go around serving a static file using servicestack?

I would like to add a route like Routes.Add(/app) and when a client issues a GET for this path i need to return the a silverlight xap file.


回答1:


ServiceStack is already be able to serve static files by referencing them directly.

Otherwise if you want a service return a file for downloading, you can do so with:

return new HttpResult(new FileInfo("~/app.xap"), asAttachment:true) {
   ContentType = "application/x-silverlight-app"
};

Note: asAttachment will control whether or not to send HTTP Content-Disposition headers.

More info about ServiceStack's responses is in this earlier question: ServiceStack and returning a stream



来源:https://stackoverflow.com/questions/12120276/serving-a-static-file-with-servicestack

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!