Whilst creating a JsonResult for my web service in ASP.NET MVC I received a deserialisation error of type "InvalidOperationException" with the description "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property."
In fairness I was sending quite a large JSON object at the time, largely due to there being 288 base64 embedded images totally ~15MB I'd guess... Whoops! Anyway, it may be a hilariously large amount of data but it is what I want so how to work around this?...
There is a web config setting that can resolve this which was my first discovery in my path to success:
<system.web.extensions> <scripting> <webServices> <jsonSerialization maxJsonLength="1000000000" /> </webServices> </scripting> </system.web.extensions>
This is the official word from Microsoft about this but unfortunately this only works when you are specifically serialising (or deserialising) things yourself. This has no relation on the inner workings of the framework such as my bit of MVC code which is currently as follows:
public JsonResult GetData() { return Json(GetCrazyAmountOfJson(), JsonRequestBehavior.AllowGet); }
So for those of you using the Json() method in ASP.NET MVC or some other similar .NET framework voodoo like me the work around is to write your own code and bypass the framework such as:
public ContentResult GetData() { var data = GetCrazyAmountOfJson(); var serializer = new JavaScriptSerializer(); serializer.MaxJsonLength = int.MaxValue; var result = new ContentResult(); result.Content = serializer.Serialize(data); result.ContentType = "application/json"; return result; }
The MaxJsonLength is an Int32 so the maximum length can only be the maximum int value (1.4billion or something), you cannot make it unlimited. I assume this limit is here to make you think twice before making crazy big JSON serlisations. Did it?
The post is absolutely fantastic! Lots of great information and inspiration both of which we all need! Also like to admire the time and effort you put into your blog and detailed information you offer! I will bookmark your blog!
ReplyDeleteOutdoor Furniture
Thanks lot.
ReplyDeleteThis solved my problem.
Thank you so much. That solved my problem too.
ReplyDeleteGreat informative site. I'm really impressed after reading this blog post. I really appreciate the time and effort you spend http://www.proessaywriting.com/write-my-essay/ to share this with us! I do hope to read more updates from you.
ReplyDeletevery nice . thank you for sharing information http://awriter.org/rushessaycom/
ReplyDeleteWow! Now that you told about this method it looks so easy. Why haven't I thought about it myself when was struggling with one of the online essay writing websites??
ReplyDeleteGood article, but it would be better if in future you can share more about this subject. Keep posting.
ReplyDeletetheworldseasiestgame.com worldshardestgame.online governorofpoker2.co
Avriq MAP
ReplyDeleteAvriq
CCTV Camera
Pest control services
PC Optimization
CP Plus
Termite control services
http://greenfarm3mod.xyz/apk/
ReplyDeletehttp://bullyanniversaryeditionmod.xyz/apk/
https://mxplayerpro.xyz/apk/
weight loss supplement
ReplyDeleteweight loss supplement
Sleeping pills
Motifz Designer Lawn. 1, 2 & 3 Piece Unstitched Premium Embroidered Lawn 2019, Premium Lawn, Lawn 2019, Best lawn collection, Motifz, Best Lawn in Pakistan, Shipping worldwide. Stitching option available.
ReplyDeleteHmm… I interpret blogs on a analogous issue, however i never visited your blog. I added it to populars also i’ll be your faithful primer. wireless outdoor home security cameras
ReplyDeleteWholesale printed custom perfume boxes with the highest quality and affordable prices. Free worldwide Delivery and free Custom Perfume Boxes design.
ReplyDeleteThe beautiful actress, a beauty icon Lauren Bacall was born on September 16, 1924 in USA.
ReplyDeleteBuy online wholesale printed custom makeup boxes and packaging at easy prices and shipping worldwide, with 24/7 customer support. Get a free custom quote now!!
ReplyDeleteBuy online wholesale printed custom candle boxes and packaging at easy prices and shipping worldwide, with 24/7 customer support. Get a free custom quote now!!
ReplyDeleteBlackbird packaging provide you with any size, shape design, lipstick boxes sooner than any other packaging competitor in the market
ReplyDeletePackaging town is a one stop solution for the short-run cream boxes, Wholesale Custom Boxes needs and supplies. At affordable prices. Request a free quote now.
ReplyDeletemylar label bags in stock now. Ready made Cali pack designs. Fast Shipping at Your Supplies. Custom designs available
ReplyDeleteGot some useful knowledge from this post which you have shared here about surveillance camera which is good for home security. Thanks for sharing ithome security cameras
ReplyDeleteGreat Article
ReplyDeleteCloud Computing Projects
Networking Projects
Final Year
Projects for CSE
JavaScript Training in Chennai
JavaScript
Training in Chennai
The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals,
Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer.
Angular Training
Blackbird packaging provide you with any size, shape design, custom pet food packaging sooner than any other packaging competitor in the market
ReplyDeleteBlackbird packaging provide you with any size, shape design, bath bomb boxes wholesale sooner than any other packaging competitor in the market
ReplyDeleteBlackbird packaging provide you with any size, shape design, custom bath bomb boxes wholesale sooner than any other packaging competitor in the market
ReplyDeleteThanks for sharing the article...You write very well...If you need backlinks please reach me on genuinehotelescorts@gmail.com
ReplyDeleteCall Girls in Jaipur
Call Girls in Jaipur
Call girls in Jaipur
Call Girls in Delhi
Call Girls in Guwahati
Call Girls in Guwahati
Call Girls in Guwahati
Call Girls in Guwahati
Call Girls in Aerocity
Call Girls in Lucknow
Blackbird packaging company can provide you with any size, shape design, and custom vape cartridge packaging sooner than any other packaging competitor in the market
ReplyDeleteTruly, this article is really one of the very best in the history of articles. I am a antique ’Article’ collector and I sometimes read some new articles if I find them interesting.
ReplyDeleteLove back Solution Specialist
Vashikaran specialist
Love Vashikaran Specialist
Vashikaran Specialist in Chennai Vashikaran Specialist in Jaipur Vashikaran Specialist in Karnataka Vashikaran Specialist in London UK Vashikaran Specialist in Dubai Vashikaran Specialist in Australia Vashikaran Specialist in Punjab
buy business card boxes wholesale online from packaging town at best prices. Get Free shipping
ReplyDeletebuy boxes for business cards from packaging town at best prices. Get free shipping.
ReplyDeleteShop Men Zipper Hoodies online in a wide range of colors and styles at Wild Goat. Winter Zipper Hoodies Collection in long and short hoodies in variety of colors is now available at Wild Goat. View our wide collection of men's zipper hoodies and stock up your wardrobe now. Prices of our zipper hoodies are too low to miss.
ReplyDeleteShop Electronics online Goods at Al-Fatah, Pakistan’s leading chain of departmental stores. Shop from a huge range of top brands Home Appliances, Smart-tech and Phones and Sound bars from Al-Fatah. Shop from huge range of electronics available at Al-Fatah. Avail Free Delivery on orders above 1000 PKR in selected cities.
ReplyDeleteBlackbird packaging company can provide you with any size, shape design, and wholesale cookie boxes sooner than any other packaging competitor in the market
ReplyDeleteBuy pret collection 2021 online from Ilaha Clothing at best prices.get free shipping.
ReplyDeleteBlackbird packaging company can provide you with any size, shape design, and wholesale cookie boxes sooner than any other packaging competitor in the market
ReplyDeletebuy lawn collection 2021 online from Ilaha clothing at best prices. Get free shipping.
ReplyDeleteBlackbird packaging provide you with any size, shape design, cookie packaging boxes wholesale sooner than any other packaging competitor in the market
ReplyDeletePackaging town is a one stop solution for the short-run custom display boxes needs and supplies. At affordable prices. Request a free quote now.
ReplyDeleteinsulins online pakistan online from Medisense.pk. Get free shipping.
ReplyDeleteThanks for sharing information with us…satisfied after visiting your blog…. Learn the latest trends & their practical application by experts with us…you can contact us click on
ReplyDeleteVisit ISMT India
Welcome to Nova Clinic! Transform your look and shape of your body with our unparalleled services. We are proud to be ranked among the plastic surgery dubai. We are focused and dedicated to not only meet but also exceed the expectations of our clients and provide them with the results that they always wanted.
ReplyDeletebuy cosmetics online in pakistan from alfatah at best prices delivered at your doorstep. get free delivery
ReplyDeleteBuy gym bottoms from dshred at easy prices delivered at your doorstep. Get free shipping.
ReplyDeletebuy sports inner wear online from dshred at easy prices delivered at your doorstep. Get free shipping
ReplyDeletebuy gym bottoms online from dshred at best prices delivered at your doorstep. Get free shipping
ReplyDeleteNDURE brings you its wide range of Men's t-shirt. Now you can buy your favorites with just a tap. You can find our t-shirts online by logging into our site. Our shirts are made with pure fabric that makes you stand out. So don't wait around and shop from our collection of online t-shirts.
ReplyDeletebuy sports bra for girls online from Dshred at easy prices delivered at your doorstep. Get free shipping
ReplyDeletebuy leggings for women online from dshred at easy prices delivered at your doorstep. Get free shipping
ReplyDeleteBuy mens gym trousers online from Dshred at best prices delivered at your doorstep. Get free shipping
ReplyDeleteBuy lightweight vest online from Dshred at best prices delivvered at your doorstep. Get free shipping
ReplyDeleteBuy sports bra online from ndure at best prices delivered at your doorstep. Get free shipping.
ReplyDeleteBuy makeup online from Al-Fatah at best prices delivered at your doorstep. Get free shipping
ReplyDeleteShop for a huge range kids strollers, nursing and feeding products, school essentials, carriers, toys online, clothing for boys, girls and babies at Al-Fatah, Pakistan’s leading chain of departmental stores. Shop from a huge range of top brands for kids from Al-Fatah. Free Delivery on orders above 1000 PKR in selected cities
ReplyDeletebuy home appliances online from Al-Fatah at best prices delivered at your doorstep. Get free shipping.
ReplyDeleteBorjan offers its customers the best ladies khussa shoes online in Pakistan. We have the highest quality ladies khussa in Pakistan for the most affordable prices. Get Borjan's amazing collection of ladies khussa online and from outlets. Get your favorite khussas online from Borjan to keep yourself in style and comfort at the same time.
ReplyDeletethe best Situs Judi Slot Online
ReplyDeleteNdure offers their customers the highest quality hoods and pullover hoodies for kids. Get the best available boys Hoodies and hoodies for girls in Pakistan. All types of denim jackets for girls so they can stay in comfort without compromising on style. So, come to Ndure for amazing pullover hoodies for girls.
ReplyDeletepramatic slot online
ReplyDeleteCheck trouser designs and jeans for men from Enem Mall today.
ReplyDeleteBuy Online Summer lawn collection 2022 from Seran. Pakistani Top Designer embroidered Suits. Visit Our website now.
ReplyDeleteHi there
ReplyDeleteVery nice content and blog, I found it very informative and useful, hope to read more nice articles like this one around here,
Keep sharing the best content,
Best regards!
Your follower
Salvatore from:
Compra de Ingresso on-line – Os ingressos para visitar o Patrimônio Mundial Natural e uma das 7 Maravilhas da Natureza, que abriga as Cataratas do Iguaçu, são limitados e vendidos exclusivamente on-line, com agendamento de dia e horário para o passeio no site Tour Cataratas. Conheça também: Hotel das Cataratas É importante lembrar que não existe a opção de compra de bilhete físico no parque. É necessário adquirir o ingresso de entrada no Parque Nacional do Iguaçu com antecedência em sites autorizados.
Thanks and take care