我有以下方法从远程服务器读取响应
public string GetResponse()
{
string url = "http://remoteserver.com/getdata.jsp?id=515";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream = new
StreamReader(response.GetResponseStream(), enc);
string ServerResponse = loResponseStream.ReadToEnd();
loResponseStream.Close();
response.Close();
return ServerResponse;
}
在我的actionresult
我调用这个方法如下
public ActionResult Index()
{
string resp= GetResponse();
return View();
}
现在不是显示我查看浏览器而是提示我保存文件。如何避免这种情况并正常显示视图