M
M
Matsun2017-03-29 12:21:14
JavaScript
Matsun, 2017-03-29 12:21:14

Wrong encoding when passing from controller to view using AJAX - how to fix?

The controller has such a thing:
(specially simplified it)

//AJAX запрос на загрузку миниатюры
        [HttpPost]
        public ActionResult AddThumbnail()
        {
            HttpPostedFileBase image = Request.Files["fileInput"];
            switch (image.FileName)
            {
                case "noimg.jpg":
                    return new HttpStatusCodeResult(406, "Формат загруженной картинки не подходит");
                default:
                    return Json("Успешно загрузили");
            }
        }


For AJAX file uploads, I use the
jQuery Upload File Plugin

. The text passed to the constructor new HttpStatusCodeResult(406, "The format of the uploaded image does not match");
It is displayed in the view as follows:
2017-03-29_121924.png

Lebedev's decoder decoded the phrase as follows: The format of the loaded picture is not suitable → The format of the loaded picture is

not suitable
CP1252 → CP1251

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AK, 2017-08-08
@questor

Only ASCII characters are allowed in HTTP headers. Read more here: https://ru.stackoverflow.com/q/703298/213987

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question