2011-03-08 3 views
3

나는 이미지 데이터의 스트림을 반환하는 WCF 안정/http 메서드로 작업하고있다. 콘텐츠 유형이 "image/png"로 표시되어 있는지 확인하고 싶습니다. 이 메서드는 다음과 같이 정의됩니다.WCF WebGet 메서드에 대해 ContentType을 설정할 수 있습니까?

[ServiceContract] 
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] 
public class TileImageService 
{ 
    [WebGet(UriTemplate = "{id}")] 
    public Stream GetTileImage(string id) 
    { 
     Bitmap bmp = new Bitmap(173, 173); 
     Graphics g = Graphics.FromImage(bmp); 

     g.Clear(Color.Blue); 
     g.DrawString(DateTime.Now.ToLongTimeString(), new Font("Chiller", 20), Brushes.White, new PointF(10, 10)); 
     g.Flush(); 

     MemoryStream ms = new MemoryStream(); 
     bmp.Save(ms, ImageFormat.Png); 

     ms.Seek(0, SeekOrigin.Begin); 

     return ms; 
    } 
} 

Firefox에서는 콘텐츠 형식이 application/octet stream으로 표시되는 것처럼 보입니다. 콘텐츠 유형을 변경하는 방법이 있습니까?

답변

7

미안 난 그냥 내가 전에했던 기억했다

WebOperationContext.Current.OutgoingResponse.ContentType = "text/html"; // or anything 
관련 문제