H
humbleaptience
I have a php script that did this before, I want to move it to asp.net
I am getting ~30kbps download speeds with this asp.net code. The php
seems to be lightening fast.
Help!
HttpWebRequest webreq = WebRequest.Create(WMSReq.ToString()) as
HttpWebRequest;
HttpWebResponse webrep = webreq.GetResponse()
as HttpWebResponse;
System.IO.Stream streamResp =
webrep.GetResponseStream();
int readbytes = 0;
Response.ClearContent();
string imgtype = "";
if (fileformat.Substring(0, 1).ToUpper() ==
"P")
{
Response.ContentType = "image/PNG";
}
else if (fileformat.Substring(0, 1).ToUpper()
== "J")
{
Response.ContentType = "image/JPEG";
}
else if (fileformat.Substring(0, 1).ToUpper()
== "T")
{
Response.ContentType = "image/TIF";
}
Response.Buffer =
false;
byte[] responseBuffer = new byte[32768];
Server.ScriptTimeout = 600;
while ((readbytes =
streamResp.Read(responseBuffer, 0, responseBuffer.Length)) > 0)
{
if (Response.IsClientConnected == true)
Response.OutputStream.Write(responseBuffer, 0, readbytes);
Response.Flush();
}
streamResp.Close();
Response.End();
I am getting ~30kbps download speeds with this asp.net code. The php
seems to be lightening fast.
Help!
HttpWebRequest webreq = WebRequest.Create(WMSReq.ToString()) as
HttpWebRequest;
HttpWebResponse webrep = webreq.GetResponse()
as HttpWebResponse;
System.IO.Stream streamResp =
webrep.GetResponseStream();
int readbytes = 0;
Response.ClearContent();
string imgtype = "";
if (fileformat.Substring(0, 1).ToUpper() ==
"P")
{
Response.ContentType = "image/PNG";
}
else if (fileformat.Substring(0, 1).ToUpper()
== "J")
{
Response.ContentType = "image/JPEG";
}
else if (fileformat.Substring(0, 1).ToUpper()
== "T")
{
Response.ContentType = "image/TIF";
}
Response.Buffer =
false;
byte[] responseBuffer = new byte[32768];
Server.ScriptTimeout = 600;
while ((readbytes =
streamResp.Read(responseBuffer, 0, responseBuffer.Length)) > 0)
{
if (Response.IsClientConnected == true)
Response.OutputStream.Write(responseBuffer, 0, readbytes);
Response.Flush();
}
streamResp.Close();
Response.End();