本文整理汇总了C#中Response.Contents方法的典型用法代码示例。如果您正苦于以下问题:C# Response.Contents方法的具体用法?C# Response.Contents怎么用?C# Response.Contents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response.Contents方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResponseContents
private static IEnumerable<byte> GetResponseContents(Response response)
{
var ms = new MemoryStream();
response.Contents(ms);
ms.Flush();
return ms.ToArray();
}
示例2: SerializableResponse
public SerializableResponse(Response response, DateTime expiration)
{
this.Expiration = expiration;
this.ContentType = response.ContentType;
this.Headers = response.Headers;
this.StatusCode = response.StatusCode;
using (var memoryStream = new MemoryStream())
{
response.Contents(memoryStream);
this.Contents = Encoding.UTF8.GetString(memoryStream.GetBuffer().Where(a => a != 0).ToArray());
}
}
示例3: ConsistencyTestImpl
private static void ConsistencyTestImpl(string filePath, Response r)
{
Assert.Equal(HttpStatusCode.OK, r.StatusCode);
byte[] expected = File.ReadAllBytes(filePath);
MemoryStream ms = new MemoryStream();
r.Contents(ms);
ms.Flush();
byte[] actual = ms.ToArray();
Assert.Equal(expected, actual);
}