我有一个控制台应用程序,使用20个左右的线程连接到远程Web服务器并发送相当小的大小的任意http请求,超过ssl 100%.远程Web服务器实际上是一个完整的负载平衡数据中心,其中包含高可用性系统,每秒可处理数十万个请求.这不是服务器或带宽问题.话虽如此,我没有运行它,也没有对它的配置有任何影响,所以即使我想,我也无法进行服务器端更改.
当使用fiddler运行应用程序时,应用程序执行速度惊人.当没有在小提琴手中运行时,它实际上要慢得多,以至于对于手头的任务毫无用处.它似乎也在某个时刻锁定在过程的早期,但这可能只是一个死锁问题,我还不确定.
无论如何,小提琴作为代理,无疑是以某种方式修改我的请求/连接,以确保良好的吞吐量,但我不知道它在做什么.我试图找出它,以便我可以强制我的.net应用程序模仿小提琴程序连接处理行为,而不必实际通过fiddler运行它
我已粘贴下面的连接代码.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
namespace Redacted
{
public class HiveCommunicator
{
public static IResponse SendRequest(IRequest request) {
ServicePointManager.DefaultConnectionLimit = 60;
ServicePointManager.Expect100Continue = false;
string hostUrlString = string.Empty;
if (request.SiteID <= 0)
hostUrlString = string.Format("{0}://{1}{2}", request.UseSSL ? "https" : "http", DataCenters.GetCenter(request.DataCenter), request.Path);
else
hostUrlString = string.Format("{0}://{1}{2}", request.UseSSL ? "https" : "http", DataCenters.GetCenter(request.DataCenter), string.Format(request.Path, request.SiteID));
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(hostUrlString);
switch (request.ContentType)
{
default:
case ContentTypes.XML:
webRequest.ContentType = "application/xml";
break; …Run Code Online (Sandbox Code Playgroud) 在<input type="file" />mvc3站点上使用标准时,您可以通过创建类型的输入参数HttpPostedFile 并将表单设置为,在操作方法中接收文件enctype="multipart/form-data"
这种方法的一个问题是请求没有完成,并且在上传文件的全部内容之前,请求不会传递给您的操作方法.
我想在该文件上传到服务器时做一些事情.基本上我想异步接收数据,然后以编程方式逐字节处理数据.
为了实现上述目标,我想你可能需要在HttpModule或自定义HttpHandler中处理这部分请求.我熟悉这些东西是如何工作的,但我不熟悉接收文件上传数据的方法.
我知道这是可能的,因为我过去曾与第三方组件合作(通常这样他们可以报告上传进度,或者将数据缓存到磁盘以避免iis/asp.net内存限制).不幸的是,我使用的所有组件都是封闭源代码,因此我无法窥视内部并看到它们正在做什么.
我不是在寻找代码,但有人可以让我指出正确的方向吗?
使用.net 4.0在win 7上运行asp.net mvc 2
我有一个控制器动作方法,从一个窗体接收2个DateTime对象.表单上的UI使用jQueryUi datepicker(不确定是否匹配).
填写该表格的用户将始终输入夏威夷时区的日期/时间.
我想将其转换为UTC时间并将其存储在数据库中.
当我调用TimeZoneInfo.ConverTime(DateTime,TimeZoneInfo,TimeZoneInfo)时,它返回与我传入的完全相同的日期时间,而不进行任何转换.我检查了调试器,唯一改变的是它将DateTime.Kind属性更改为DateTimeKind.Utc.
public ActionResult New(ScheduleNew data){
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById( "Hawaiian Standard Time" );
DateTime start = TimeZoneInfo.ConvertTime(data.StartDate, tz, TimeZoneInfo.Utc);
DateTime end = TimeZoneInfo.ConvertTime(data.EndDate, tz, TimeZoneInfo.Utc);
}
Run Code Online (Sandbox Code Playgroud)
我也试过了另一个版本,结果相同.
public ActionResult New(ScheduleNew data){
DateTime start = new DateTime( data.StartDate.Year, data.StartDate.Month, data.StartDate.Day, data.StartDate.Hour, data.StartDate.Minute, data.StartDate.Second, DateTimeKind.Unspecified );
DateTime end = new DateTime( data.EndDate.Year, data.EndDate.Month, data.EndDate.Day, data.EndDate.Hour, data.EndDate.Minute, data.EndDate.Second, DateTimeKind.Unspecified );
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById( "Hawaiian Standard Time" );
StartDate = TimeZoneInfo.ConvertTime(start, tz, TimeZoneInfo.Utc);
EndDate …Run Code Online (Sandbox Code Playgroud)