在asp.net中测量internet速度
我正在开发一个网站,它需要根据互联网速度/带宽来改变内容 在带宽较低的地方,web应用程序应该只显示 纯文本,对于正常带宽,显示正常网站 几天来我一直在考虑这个问题,但我还没有找到一个合适的解决办法。 在asp.net中是否有一种检测带宽的简单方法在asp.net中测量internet速度,asp.net,bandwidth,Asp.net,Bandwidth,我正在开发一个网站,它需要根据互联网速度/带宽来改变内容 在带宽较低的地方,web应用程序应该只显示 纯文本,对于正常带宽,显示正常网站 几天来我一直在考虑这个问题,但我还没有找到一个合适的解决办法。 在asp.net中是否有一种检测带宽的简单方法 谢谢请查看以下链接,希望您能从服务请求中了解有关带宽检查的想法 按照给定的代码检查您的internet连接速度 添加名称空间 Net系统 在测试按钮上写入代码单击事件 Uri URL = new Uri("http://sixhoej.net
谢谢请查看以下链接,希望您能从服务请求中了解有关带宽检查的想法
按照给定的代码检查您的internet连接速度 添加名称空间 Net系统 在测试按钮上写入代码单击事件
Uri URL = new Uri("http://sixhoej.net/speedtest/1024kb.txt");
WebClient wc = new WebClient();
double starttime = Environment.TickCount;
// download file from the specified URL, and save it to C:\speedtest.txt
wc.DownloadFile(URL, @"C:\speedtest.txt");
// get current tickcount
double endtime = Environment.TickCount;
// how many seconds did it take?
// we are calculating this by subtracting starttime from endtime
// and dividing by 1000 (since the tickcount is in miliseconds.. 1000 ms = 1 sec)
double secs = Math.Floor(endtime - starttime) / 1000;
// round the number of secs and remove the decimal point
double secs2 = Math.Round(secs, 0);
// calculate download rate in kb per sec.
// this is done by dividing 1024 by the number of seconds it
// took to download the file (1024 bytes = 1 kilobyte)
double kbsec = Math.Round(1024 / secs);
Label1.Text = "Download rate: " + kbsec + " kb/sec";
try
{
// delete downloaded file
System.IO.File.Delete(@"C:\speedtest.txt");
Response.Write("Done.");
}
catch
{
Response.Write("Couldn't delete download file.");
Response.Write("To delete the file yourself, go to your C-drive and look for the file 'speedtest.txt'.");
}
可能重复的