![](/img/trans.png)
[英]The parameters dictionary contains a null entry for parameter 'talepID' of non-nullable type 'System.Int32'
[英]The parameters dictionary contains a null entry for parameter 'imageWidth' of non-nullable type 'System.Int32'
我有一个对ActionResult进行ajax调用的函数,它会发送上载图像的base64字符串以及一些其他有关图像尺寸信息的参数。 数据将发送到服务器以进行大小调整。 ajax调用看起来像这样
$.ajax({
type: 'POST',
data: {
b64: data.data,
imageWidth: data.imageWidth,
imageHeight: data.imageHeight,
imageOriginalWidth: data.imageOriginalWidth,
imageOriginalHeight: data.imageOriginalHeight
},
url: '/Image/Resize',
beforeSend: function () {
//stuff
},
success: function (data) {
//stuff
},
error: function (response) {
//stuff
}
});
该数据对象是从一个回调函数中检索的,该函数获取了我上面提到的所有信息。 现在,我放置了断点并确保该对象实际上具有值。
我也在Fiddler中查看了请求,一切看起来都很好。 奇怪的是,这并不总是发生。 仅当我尝试上传太大的gif时,它才会发生。 当文件的大小不超过2MB时,不会发生此错误。 为了澄清,我不发送文件,只是base64字符串。
我不知道问题是b64
字符串太大还是其他,但是查看服务器的响应,我看到的仅仅是这个
参数字典包含用于方法'System.Web.Mvc.ActionResult Resize(System.String,Int32,Int32,Int32,Int32)'的非空类型'System.Int32'的参数'imageWidth'的空条目
这是ActionResult的样子
[HttpPost]
public ActionResult Resize(String b64, int imageWidth, int imageHeight, int imageOriginalWidth, int imageOriginalHeight)
{
//....
}
当我尝试上传另一个较小的文件时,一切正常,并且没有出现此错误。 抱歉,如果您以前已经回答过这个问题,但是到处都没有找到答案。 我尝试过更改ajax调用中的dataType
,尝试过字符串化,然后查看了请求标头。
内容长度:4849982内容类型:application / x-www-form-urlencoded; 字符集= UTF-8
我不知道我在想什么。 任何帮助,将不胜感激。 多谢你们。
b64已删除
imageWidth 906
imageHeight 509
imageOriginalWidth 500
图片原图高度281
终于找到了解决办法。 事实证明,向服务器发出请求时输入流缓冲阈值的默认限制为4 MB
您需要做的只是转到您的web.config
文件并添加以下内容:
<configuration>
<system.web>
<httpRuntime maxRequestLength="xxx" />
</system.web>
</configuration>
其中“ xxx”是您想要的大小( KB)
对于IIS 7+,您还需要添加以下内容:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="xxx" />
</requestFiltering>
</security>
</system.webServer>
默认值等于30 MB
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.