我限制文件大小用户可以从Web.config上传到站点.正如解释在这里,它应该抛出一个ConfigurationErrorsException如果大小是不能接受的.我试图从动作方法或控制器中捕获上传请求,但没有运气.连接被重置,我无法显示错误页面.
我尝试在BeginRequest事件中捕获它,但无论我做什么,异常都是未处理的.这是代码:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
HttpContext context = ((HttpApplication)sender).Context;
try
{
if (context.Request.ContentLength > maxRequestLength)
{
IServiceProvider provider = (IServiceProvider)context;
HttpWorkerRequest workerRequest = (HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest));
// Check if body contains data
if (workerRequest.HasEntityBody())
{
// get the total body length
int requestLength = workerRequest.GetTotalEntityBodyLength();
// Get the initial bytes loaded
int initialBytes = 0;
if (workerRequest.GetPreloadedEntityBody() != null)
initialBytes = workerRequest.GetPreloadedEntityBody().Length;
if (!workerRequest.IsEntireEntityBodyIsPreloaded())
{
byte[] buffer = new byte[512];
// Set the received bytes to …Run Code Online (Sandbox Code Playgroud) 我有一个使用wsHttpBinding的WCF服务.服务器配置如下:
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)
在客户端,我包括WCF服务的服务参考.如果我的功能有限,在我的IService中说90操作合同但是如果再添加一个OperationContract而不是我无法更新服务引用,我也能添加该服务引用.在这个文章它提到,在这些配置文件仍改变这些配置文件(即devenv.exe.config,WcfTestClient.exe.config和SvcUtil.exe.config),它会工作,但即使包括那些绑定的错误弹出说
下载' http://10.0.3.112/MyService/Service1.svc/mex '时出错.请求失败,HTTP状态为400:错误请求.元数据包含无法解析的引用:' http : //10.0.3.112/MyService/Service1.svc/mex '.XML文档中存在错误(1,89549).读取XML数据时已超出最大名称字符集计数配额(16384).nametable是用于存储XML处理期间遇到的字符串的数据结构 - 具有非重复元素名称,属性名称和属性值的长XML文档可能会触发此配额.通过更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象上的MaxNameTableCharCount属性,可以增加此配额.第1行,位置89549.如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用.
不知道怎么解决这个????
在我们公司,我们将每个Javascript文件合并为一个大的(大约700kb但正在增长)缩小和压缩的Javascript文件.我试图评估每个页面使用一个大的Javascript文件(缩小和gzip)和使用几个Javascript文件之间的性能差异,每个页面一个.
一个明显的区别是,大型Javascript文件可以在浏览器加载到第一页请求后缓存,之后产生的开销很小,而在使用多个js文件时,每个不同的页面上至少会有一个未缓存的get请求.所以我会为较慢的连续初始页面加载交易较慢的第一个初始页面加载.
为了找出什么时候缓慢的初始页面加载(使用一个大的Javascript文件)将成为足以证明将合并文件分解为更小的文件和更改我们的构建过程的工作的合理性,我想知道它有多长需要解析代码,因此我可以估计总加载和解析时间.
到目前为止,我的方法是将一个脚本标记添加到测试页面,该页面占用当前时间,使用Javascript附加一个大的脚本,之后再次测量时间,如下所示:
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script')
script.setAttribute('type', 'text/javascript');
script.src = 'path/700kbCombineFile.js';
start_time = new Date().getTime();
head.appendChild(script);
Run Code Online (Sandbox Code Playgroud)
在700kbCombineFile.js的末尾,我附上:
console.log(new Date().getTime() - start_time)
Run Code Online (Sandbox Code Playgroud)
然后我减去从firebug获得的网络传输时间,对于700 kb文件接收大约700ms,对于300 kb文件接收大约300ms.
这种方法有意义吗?为什么不?有没有更好的方法/任何工具来做到这一点?
我需要仅从控制器操作中返回具有返回类型ActionResult的所有操作中的方法.我从以下获取控制器名称和操作名称..
string originController = filterContext.RouteData.Values["controller"].ToString();
string originAction = filterContext.RouteData.Values["action"].ToString();
Run Code Online (Sandbox Code Playgroud)
但是我怎样才能过滤只有返回类型ActionResult的方法?
刚开始猪; 尝试从文件加载数据并从此转储它.加载似乎是正确的,不会抛出任何错误.以下是查询:
NYSE = LOAD'/root/Desktop/Works/NYSE-2000-2001.tsv'使用PigStorage()AS(交换:chararray,stock_symbol:chararray,日期:chararray,stock_price_open:float,stock_price_high:float,stock_price_low:float,stock_price_close :float,stock_volume:int,stock_price_adj_close:float);
当我尝试执行转储时,它会抛出以下错误:
错误1066:无法为别名打开迭代器NYSE org.apache.pig.impl.logicalLayer.FrontendException:错误1066:无法在org.apache.pig.PigServer.openIterator(PigServer.java:857)处打开别名NYSE的迭代器org.apache.pig.tools.grunt.GruntParser.processDump(GruntParser.java:682)位于org.apache.pig的org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:303). tools.grunt.GruntParser.parseStopOnError(GruntParser.java:189)位于org.apache.pig.tools.grunt.Grunt.run的org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:165) Grunt.java:69)org.apache.pig.Main.run(Main.java:490)atg.apache.pig.Main.main(Main.java:111)引起:java.io.IOException:Job在org.apache.pig.PigServer.openIterator(PigServer.java:849)中以异常状态FAILED终止
知道是什么导致了这个问题吗?
看到即使是最专业的网站也做错了也很烦人.发布的文字变成了不可读的东西.我没有太多关于编码的信息.我只是想知道这样一个基本的东西如此困难的问题.
这有绝对的解决方案吗?它可能有其限制,但StackOverflow似乎使其工作.
一种方法是使用这两个插件来创建谷歌+风格的照片显示http://www.sohtanaka.com/web-design/fancy-thumbnail-hover-effect-w-jquery/并且还有大量其他滑块插件可用.通过合并两个我们可以做各自的工作.但我不想重新发明轮子.
有没有插件已经可用.. ??
我有时会发现自己正在考虑在引用时使用哪个词IEnumerable<Foo>.我不认为我在阅读时会看到一致的命名.
IEnumerable<Foo>:这是一个类型名称.在思考或使用句子时没有用处.
收藏:它是有效的,但并不是随处可见.虽然我们有System.Collections命名空间.
顺序:它也是有效的,可能更好地定义它.
枚举器或迭代器:他们强调操作,很少使用.
什么是最合适的?你在代码中读到了什么?
我试图datepicker显示我发送的日期名称,但它仍然使用默认值.有什么东西应该关掉吗?我应该用单个选项语句设置值吗?我在Firebug中没有任何错误.这是我的代码:
$('#<%= txtDate.ClientID %>').datepicker({
dateFormat: 'dd/mm/yy',
changeMonth: true,
changeYear: true,
yearRange: "-50:+10",
clickInput: true,
dayNames: <%= DayNames %> ,
dayNamesMin: <%= DayNamesMin %> ,
monthNames: <%= MonthNames %> ,
montNamesShort: <%=MonthNamesShort %>
});
Run Code Online (Sandbox Code Playgroud)
这是输出:
$(document).ready(function () {
$('#ctl00_ctl00_ctl00_body_body_CenterColumn_CvPersonalInfoControl_birthDate_txtDate').datepicker({
dateFormat: 'dd/mm/yy',
changeMonth: true,
changeYear: true,
yearRange: "-50:+10",
clickInput: true,
dayNames: ['Pazartesi', 'Sal?', 'Çar?amba', 'Per?embe', 'Cuma', 'Cumartesi', 'Pazar'] ,
dayNamesMin: ['Pzt', 'Sa', 'Çr?', 'Pr?', 'Cu', 'Cmt', 'Pzr'] ,
monthNames: ['Ocak', '?ubat', 'Mart', 'Nisan', 'May?s', 'Haziran', 'Temmuz', 'A?ustos', 'Eylül', 'Ekim', 'Kas?m', …Run Code Online (Sandbox Code Playgroud) Visual Studio 2015 Pro提供以下错误:
错误BC36716:Visual Basic 9.0不支持隐式行继续.
对于以下源代码:
1 .Line.Points = New UnitPoint() _
2 {
3 New UnitPoint(Offset + OutlineBoxWidth_halph, 0),
4 New UnitPoint(Offset + OutlineBoxWidth_halph, "height"),
5 New UnitPoint(Offset + OutlineBoxWidth, "height")
6 }
Run Code Online (Sandbox Code Playgroud)
当我在第2行到第5行插入延续字符时,编辑器将光标移离该行时将其删除
它曾用于编译好但有些东西已经改变了.什么?
asp.net-mvc ×2
c# ×2
javascript ×2
jquery ×2
.net ×1
apache-pig ×1
asp.net ×1
datepicker ×1
html ×1
ienumerable ×1
ienumerator ×1
linq ×1
non-english ×1
svcutil.exe ×1
wcf ×1
web-config ×1