以字符串c#.net的形式获取响应 [英] getting response as a string c#.net
本文介绍了以字符串c#.net的形式获取响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在页面加载事件中使用c#.net创建了网站
i have created the website with c#.net in a page load event as
protected void Page_Load(object sender, EventArgs e)
{
string s = "completed.";
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(s);
Response.OutputStream.Write(bytes, 0, bytes.Length);
}
当我通过浏览器运行时,得到的正确响应为
when i am running through browser i am getting a correct response as
Completed.
现在我的问题是,当我通过其余客户端运行相同的URL时,我得到的响应Nody [raw]为
Now my question is when i run the same url through rest client i am getting the Response nody[raw] as
completed.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title></head>
<body>
<form method="post" action="Default.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZJy1PJCY5kS9nkQAfBTgrw0zeG/yMEs2VJP+7kbHC2Yp" />
</div> <div> </div> </form></body></html>
但是我只需要完成即可.作为回应
but i need to get only completed. as response
怎么可能?
等待您的宝贵意见和建议
Waiting for your valuable comments and suggestions
推荐答案
尝试使用:
Response.Clear();
Response.OutputStream.Write(bytes, 0, bytes.Length);
Response.End();
这篇关于以字符串c#.net的形式获取响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文