我有一個WCF REST服務必須在其方法中提供一個視頻。界面看起來像這裏(我沒有提供實現,因爲問題在這裏)。 [ContentType]
被公認,但我得到了System.Net.Mime.ContentType is a type but is used like a variable
。WCF REST服務:我得到一個System.Net.Mime.ContentType是一個類型,但像變量一樣使用
請幫忙!我知道不該做什麼
public interface MyService
{
//stream video from camera
[WebGet(ContentType("video/x-msvideo"), UriTemplate = "video/preview")]
[OperationContract]
Bitmap VideoPreview();
}
http://stackoverflow.com/questions/7967741/vendor-specific-mime-as- content-type-in-incoming-wcf-rest-post-request-eg-app –
[XY問題](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)。你有問題X(「只允許某種內容類型」)並且認爲Y(「嘗試向我的WebGet屬性添加'ContentType(foo)')可以解決這個問題。請正確解釋您的問題X,因爲Y不會工作:該屬性不支持。看看@ Faizan的建議。 – CodeCaster
添加內容類型如下:WebOperationContext.Current.OutgoingResponse.ContentType =「text/xml」; – Milee