Why ASP.NET MVC default Model Binder is slow? It's taking a long time to do its work

后端 未结 3 650
心在旅途
心在旅途 2020-12-08 08:13

In a current project the client asked for the possibility of answering a questionnaire in two ways: using a Wizard (one question at a time) and Listing

相关标签:
3条回答
  • 2020-12-08 08:56

    I haven't tried this but when I use integer indices the binder had no problems in binding to the IEnumerable. Since you are not actually using these Guids I'd replace them with integers. (0,1,2...)

    I guess you could do this easily on the page that renders the form or using JS.

    0 讨论(0)
  • 2020-12-08 09:06

    This may not be the answer you are looking for, but it may help. Instead of using the FormCollection, try having a controller method accept a model in the signature and use a Ajax.BeginForm(). This will remove the need for the serialization, and allow MVC to do it's work. Also, having a model with List of type Question may be worth looking into. This approach will also seemingly remove the need to iterate through the values on the post as they will already be in the model.

    0 讨论(0)
  • 2020-12-08 09:20

    You can use ServiceStack JsonSerializer which is pretty fast in benchmark results here is documentation http://mono.servicestack.net/docs/text-serializers/json-serializer and here is the benchmarks http://mono.servicestack.net/benchmarks/

    0 讨论(0)
提交回复
热议问题