将base64从javascript传递到C#服务器函数

将base64从javascript传递到C#服务器函数,c#,javascript,.net,image,base64,C#,Javascript,.net,Image,Base64,我想通过ajax发送图像的属性,将图像保存在服务器上。。 在JS中,在发送图像之前,我将在base64中对图像进行编码(以及我需要的其他参数): 我通过以下方式在服务器端接收请求: [WebMethod] [ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)] public static JsonReturn GetData(string action, string x, string y, string

我想通过ajax发送图像的属性,将图像保存在服务器上。。 在JS中,在发送图像之前,我将在base64中对图像进行编码(以及我需要的其他参数):

我通过以下方式在服务器端接收请求:

[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public static JsonReturn GetData(string action, string x, string y, string width, string height, string type, string obj_id, string image, string team, string jersey, string spot)
{
//Process Image
}
现在奇怪的是,对于一些图像,这是有效的(我的意思是它达到了GetData函数)!当我试图发送一个更小(或更低质量)的图像时,这是可行的。当我尝试发送具有很长base64字符串的图像时,它无法到达函数


有人能想到这有什么不对吗?

谢谢你们的建议。。。对于可能寻求解决方案的任何其他人:

您必须通过将其添加到web.config中来增加maxJSONLength

<system.web.extensions>
   <scripting>
     <webServices>
        <jsonSerialization maxJsonLength="50000000"/> <!-- Set the maximum request size  (the value is in KB here) -->
     </webServices>
   </scripting>
</system.web.extensions>


您是否可以查看浏览器控制台并检查javascript错误?HTTP规范没有任何大小限制或类似的限制。但是,这是一个规范,不是巴西法律。我怀疑您达到了默认的
maxRequestLength
。试着增加它:你为什么要使用base64编码呢?使用blob并直接上传:谢谢大家的及时回复@gustavodidomenico没有javascript错误。。我刚刚收到一个内部服务器错误500,因为它甚至找不到我的GetData服务器端函数。@spender我将尝试更改maxRequestLength,看看它是如何运行的。。老实说,我在这方面还很新,我以前从未通过javascript上传过图像。我发现我可以通过base64做到这一点,这就是我试图做到的!我也会尝试实施你的blob建议,我会回来找你!再次感谢你们的帮助。。
<system.web.extensions>
   <scripting>
     <webServices>
        <jsonSerialization maxJsonLength="50000000"/> <!-- Set the maximum request size  (the value is in KB here) -->
     </webServices>
   </scripting>
</system.web.extensions>