2015-07-16 3 views
-1

У меня есть запрос ajax, который может иметь очень длинные данные (более 2000 символов). Я получаю 404 от сервера. Как я могу это решить?JQuery ajax с большими данными возвращает 404

var data= { data: /*some long text*/'Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. She packed her seven versalia, put her initial into the belt and made herself on the way. When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her hometown Bookmarksgrove, the headline of Alphabet Village and the subline of her own road, the Line Lane. Pityful a rethoric question ran over her cheek, then she continued her way. On her way she met a copy. The copy warned the Little Blind Text, that where it came from it would have been rewritten a thousand times and everything that was left from its origin would be the word "and" and the Little Blind Text should turn around and return to its own, safe country. But nothing the copy said could convince her and so it didn’t take long until a few insidious Copy Writers ambushed her, made her drunk with Longe and Parole and dragged her into their agency, where they abused her for their projects again and again. And if she hasn’t been rewritten, then they are still using her. Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. She packed her seven versalia, put her initial into the belt and made herself on the way. When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her hometown Bookmarksgrove, the headline of Alphabet Village and the subline of her own road, the Line Lane. Pityful a rethoric question ran over her cheek, then she continued her way. On her way she met a copy. The copy warned the Little Blind Text, that where it came from it would have been rewritten a thousand times and everything that was left from its origin would be the word "and" and the Little Blind Text should turn around and return to its own, safe country. But nothing the copy said could convince her and so it didn’t take long until a few insidious Copy Writers ambushed her, made her drunk with Longe and Parole and dragged her into their agency, where they abused her for their projects again and again. And if she hasn’t been rewritten, then they are still using her. Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar. The Big Oxmox advised her not to do so, because there were thousands of bad Commas, wild Question Marks and devious Semikoli, but the Little Blind Text didn’t listen. She packed her seven versalia, put her initial into the belt and made herself on the way. When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her hometown Bookmarksgrove, the headline of Alphabet Village and the subline of her own road, the Line Lane. Pityful a rethoric question ran over her cheek, then she continued her way. On her way she met a copy. The copy warned the Little Blind Text, that where it came from it would have been rewritten a thousand times and everything that was left from its origin would be the word "and" and the Little Blind Text should turn around and return to its own, safe country. But nothing the co' } 
$.ajax({ 
    url: url, 
    type: "POST", 
    dataType: "json", 
    data: data, 
    success: onSuccess, 
    error: onError 
    }); 

У меня есть метод сервера:

[HttpPost] 
public dynamic PostText(string data) 
{ 
      return data.Length; 
} 

Я использую MSSQLServer и IIS 8.5.9600

Я попытался установить maxRequestLength, как here, но это не помогло

Возможно, есть другой способ отправки данных? Я могу отправить его в разделе «тело сообщения». Но я понятия не имею, как это сделать. Я не нашел информации об этом. Но я попытался отправить его с DHC, и я мог получить данные из тела.

var s = new System.IO.StreamReader(System.Web.HttpContext.Current.Request.InputStream).ReadToEnd(); 

Вопрос в том, как добавить данные в тело в ajax?

+0

Вы были в состоянии получить ожидаемый ответ на меньший объем данных? –

+0

Ограничения сервера для поста должны быть выше, чем у него, например, на PHP это 8 Мб, я думаю, отредактируйте: на самом деле он по умолчанию ограничен по умолчанию, поскольку 5.2.12 –

+0

Обычно он зависит от настройки сервера, в PHP это 'post_max_size' – alan0xd7

ответ

0

Какой HTTP-сервер вы используете?

Вы пробовали добавить следующее в свой web.config?

<system.webServer> 
<security> 
    <requestFiltering> 
     <requestLimits maxAllowedContentLength="1000000" /> 
    </requestFiltering> 
</security> 
<system.webServer> 

Это позволит увеличить разрешенную длину контента до мегабайта. Кроме того, вы можете установить атрибут MaxReceivedMessageSize ваших WCF привязки к более 64k по умолчанию:

<webHttpBinding> 
    <binding name="MessageSizeWeb" maxReceivedMessageSize="2147483647" /> 
</webHttpBinding> 

Кроме того, вам может понадобиться изменить AppSettings в web.config:

<appSettings> 
    <add key="aspnet:MaxJsonDeserializerMembers" value="400000" /> 
</appSettings> 

Вы можете также попробуйте:

  1. Launch "Internet Information Services (IIS) Manager"
  2. Разверните поле Сервер
  3. Развернуть сайты
  4. Выберите сайт, для которого вы хотите внести изменения.
  5. В разделе Функции, дважды щелкните
  6. В разделе «Раздел» «Редактор конфигурации»
  7. выберите: system.webServer> serverRuntime
  8. Изменить раздел «UploadReadAheadSize»
  9. Нажмите Применить
+0

Он все еще не работает. – Lokki

+0

Какой сервер вы используете для размещения своего приложения? Вы только сказали нам ваш сервер базы данных. Также я увеличил значение десериализации ... – msj121

+0

О, извините. Это IIS 8.5.9600 – Lokki

Смежные вопросы