我有一个HttpHandler,我用它来处理客户端网站上的某些图像.当我将图像流输出到响应对象并偶尔调用Flush时会抛出错误.这是一个代码块
var image = Image.FromStream(memStream);
if (size > -1) image = ImageResize.ResizeImage(image, size, size, false);
if (height > -1) image = ImageResize.Crop(image, size, height, ImageResize.AnchorPosition.Center);
context.Response.Clear();
context.Response.ContentType = contentType;
context.Response.BufferOutput = true;
image.Save(context.Response.OutputStream, ImageFormat.Jpeg);
context.Response.Flush();
context.Response.End();
Run Code Online (Sandbox Code Playgroud)
根据我的阅读,这个异常是由于客户端在进程完成之前断开连接并且没有要刷新的.
这是我的错误页面的输出
System.Web.HttpException: An error occurred while communicating with the remote host. The error code is 0x80070057.
Generated: Mon, 12 Oct 2009 03:18:24 GMT
System.Web.HttpException: An error occurred while communicating with the remote host. The error code is 0x80070057.
at System.Web.Hosting.ISAPIWorkerRequestInProcForIIS6.FlushCore(Byte[] status, Byte[] header, Int32 keepConnected, …Run Code Online (Sandbox Code Playgroud) 我有一个Web服务,我通过枚举
public enum QueryType {
Inquiry = 1
Maintainence = 2
}
Run Code Online (Sandbox Code Playgroud)
当我传递一个参数为QueryType的对象时,我从Web服务中得到错误:
'2'不是QueryType的有效值
当你可以从枚举的声明中清楚地看到它是.
我无法更改枚举的值,因为遗留应用程序使用这些值,但我宁愿不必插入"默认"值来推送枚举的索引以使其与我的Web服务一起使用.它就像Web服务使用值的索引而不是值本身.
有没有人建议我能做些什么来使它工作,我的WSDL中有什么可以改变的吗?
我们正在重写我们的一些网站,并试图为我们的用户充分利用浏览器缓存.我们创建了一组共享的css文件,我们计划将其用作我们创建的多个站点的"公司品牌".
原因是,我们知道浏览器会将CSS文件缓存一段确定的时间.如果我在具有不同外壳的不同站点中指定相同的文件名,它会缓存文件的两个版本(即使它们是相同的内容),还是会识别出它是同一个文件,从而忽略了文件名的大小写
<link href="http://branding.corporateentity.com/style/screen.css" type="text/css" />
<link href="http://branding.corporateentity.com/style/print.css" type="text/css" />
Run Code Online (Sandbox Code Playgroud)
VS:
<link href="http://branding.corporateentity.com/Style/Screen.css" type="text/css" />
<link href="http://branding.corporateentity.com/Style/Print.css" type="text/css" />
Run Code Online (Sandbox Code Playgroud) 我正在使用TeamCity通过msbuild和WebDeploy构建和部署MVC应用程序集合.
在我的解决方案构建/部署之前的步骤中,我将app_offline.htm复制到deploy目录,以便我可以执行SQL更新和其他Web /解决方案管理步骤,包括构建.
WebDeploy中的一个设置是删除未包含在项目中或不需要运行站点的文件.这会每次删除我的app_offline.htm文件.虽然我理解这是一种理想的结果,但有没有办法在部署时排除此文件从部署目录中删除?
我尝试使用ExcludeFromPackageFiles选项添加一个ItemGroup,但没有结果.
我们只想将用户输入的值自动舍入到最近的.25小时间隔.因此,用户可以输入1.55,并在保存到数据库时舍入到1.50.如果用户输入1.90将2.00保存到数据库.
我使用arshaw.com/fullcalendar中的fullcalendar在企业内部网日历上显示事件.我有className属性工作,对一些代码进行了一些更改,现在无法弄清楚它为什么不起作用.这是从我的服务返回的json
[
{
"allDay":true,
"className":"corporate",
"editable":null,
"end":null,
"id":null,
"start":"2010-07-05T00:00:00.0000000",
"title":"4th of July Holiday (Day Off)",
"url":"\/en\/EmployeeResources\/Calendar\/Corporate\/2010\/07\/4th_of_july_holiday.aspx"
}
]
Run Code Online (Sandbox Code Playgroud)
一切正常,除了将'corporate'className分配给日历上的事件项.
这是我在document.ready上使用的代码,用于加载日历事件,再次,工作正常,它只是className,我遇到了麻烦
$("#calendar").fullCalendar('addEventSource', '/layouts/calendar/SitecoreCalendarEventsHandler.ashx?calendar=Corporate')
Run Code Online (Sandbox Code Playgroud)
我还要注意,我正在使用arshaw.com的最新版本(1.4.6)
好.我正在尝试与Pivotal Tracker API进行通信,该API仅返回XML格式的数据.我有以下XML,我正在尝试反序列化到我的域模型中.
<?xml version="1.0" encoding="UTF-8"?>
<stories type="array" count="2" total="2">
<story>
<id type="integer">2909137</id>
<project_id type="integer">68153</project_id>
<story_type>bug</story_type>
<url>http://www.pivotaltracker.com/story/show/2909137</url>
<current_state>unscheduled</current_state>
<description></description>
<name>Test #2</name>
<requested_by>Anthony Shaw</requested_by>
<created_at type="datetime">2010/03/23 20:05:58 EDT</created_at>
<updated_at type="datetime">2010/03/23 20:05:58 EDT</updated_at>
</story>
<story>
<id type="integer">2909135</id>
<project_id type="integer">68153</project_id>
<story_type>feature</story_type>
<url>http://www.pivotaltracker.com/story/show/2909135</url>
<estimate type="integer">-1</estimate>
<current_state>unscheduled</current_state>
<description></description>
<name>Test #1</name>
<requested_by>Anthony Shaw</requested_by>
<created_at type="datetime">2010/03/23 20:05:53 EDT</created_at>
<updated_at type="datetime">2010/03/23 20:05:53 EDT</updated_at>
</story>
</stories>
Run Code Online (Sandbox Code Playgroud)
我的'故事'对象创建如下:
public …Run Code Online (Sandbox Code Playgroud) 我一直在编写一些使用Web服务从Web检索信息的单元测试.当我从控制台应用程序运行我的代码时,我可以通过Fiddler监视调用,看看请求的内容和服务器响应.
当我通过使用TestDriven.NET运行单元测试来进行这些相同的服务调用时,调用不会显示在通过Fiddler的调用中.
有没有人需要做什么来配置它,以便我可以在运行单元测试时监视与Fiddler的调用?
我甚至不确定这是否可行,但我已经用尽所有想法来解决这个问题,所以我想我会把它发送给社区,看看你的想法.而且,如果不可能,也许你也有一些想法.
我正在尝试创建一个Attribute类,我可以将其添加到一个方法中,该方法允许我使用lambda表达式来获取方法的每个参数
public ExampleAttribute : Attribute
{
public object Value { get; set; }
public ExampleAttribute(--something here to make the lambda work--, object value)
{
Value = value;
}
}
Run Code Online (Sandbox Code Playgroud)
我想能够在下面这样的事情:
[Example(x=>x.Id, 4)]
[Example(x=>x.filter, "string value")]
public ActionResult Index(int Id, string filter)
{
return View();
}
Run Code Online (Sandbox Code Playgroud)
我知道我可能完全梦想着这个想法.我基本上试图编写一个模型来允许自我记录的REST API文档.在最近的一个项目中,我们写了十几个服务,每个服务有5到15个方法,我认为写一些东西要比这更容易,而不是为每个方法编写一个文档页面.我计划最终将它作为一个开源项目发布,一旦我把它放在一个我认为可以释放的地方.
我正在使用HtmlAgilityPack来解析HTML页面并从选择列表中检索许多选项元素.
这GvsaDivisions是一个从POST结果返回原始html的方法,在问题的上下文中是不敬的
public IEnumerable<SelectListItem> Divisions(string season, string gender, string ageGroup)
{
var document = new HtmlDocument();
var html = GvsaDivisions(season);
document.LoadHtml(html);
var options = document.DocumentNode.SelectNodes("//select//option").Select(x => new SelectListItem() { Value = x.GetAttributeValue("value", ""), Text = x.NextSibling.InnerText });
var divisions = options.Where(x => x.Text.Contains(string.Format("{0} {1}", ageGroup, gender)));
if (ageGroup == "U15/U16")
{
ageGroup = "U15/16";
}
if (ageGroup == "U17/U19")
{
ageGroup = "U17/19";
}
return divisions;
}
Run Code Online (Sandbox Code Playgroud)
我正在观察的是......一旦options.Where()执行,分区包含一个结果.在测试ageGroup == "U15/U16"和分配后ageGroup = "U15/16",分区现在包含3个结果(原始1,添加2个新匹配的新值的标准 …
c# ×6
asp.net ×2
css ×2
attributes ×1
caching ×1
enums ×1
fiddler ×1
fullcalendar ×1
html ×1
httphandler ×1
image ×1
json ×1
lambda ×1
linq ×1
rounding ×1
teamcity ×1
unit-testing ×1
web-services ×1
webdeploy ×1
wsdl ×1
xml ×1