本文介绍了获取的FormCollection出controllerContext自定义模型绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不错的功能是把我的FormCollection(从控制器提供)。现在,我想做一个模型绑定,而不是和我有粘合剂的模型调用该函数,它需要的FormCollection。出于某种原因,我能找到它。我认为这将是
controllerContext.HttpContext.Request.Form

I had a nice function that took my FormCollection (provided from the controller). Now I want to do a model bind instead and have my model binder call that function and it needs the FormCollection. For some reason I can find it. I thought it would have been controllerContext.HttpContext.Request.Form

推荐答案

试试这个:

var formCollection = new FormCollection(controllerContext.HttpContext.Request.Form)

的FormCollection是我们加入到ASP.NET MVC一种类型,都有自己的模型绑定器。你可以看一下在code为FormCollectionBinderAttribute要明白我的意思。

FormCollection is a type we added to ASP.NET MVC that has its own ModelBinder. You can look at the code for FormCollectionBinderAttribute to see what I mean.

这篇关于获取的FormCollection出controllerContext自定义模型绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 02:41