发布INT阵列控制器MVC - 什么是正确的方法签名? [英] Posting int arrays to MVC controller - what would be the correct method signature?

查看:178
本文介绍了发布INT阵列控制器MVC - 什么是正确的方法签名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是POST请求的截图(使用Firebug净面板)我派我的ASP.NET MVC2控制器。

Below is a screenshot of the POST request (using Firebug Net panel) I am sending to my ASP.NET MVC2 controller.

这是接收POST请求控制器/操作方法:

This is the controller / action method that receives the POST request:

public ActionResult Search(int[] skill, int[] discipline, int[] education, int[] marketsector){ ... }

发布的参数在我看来是正确的形式,但是操作方法接收四个空参数。你能告诉我我应该在方法签名看起来像在服务器端?或张贴这四个整数数组我MVC2控制器的一个更好的办法?

The parameters POSTed seem to me to be in the correct form, however the action method receives four null arguments. Could you please tell me what should the method signature look like on the server side? Or a better way of posting these four integer arrays to my MVC2 controller?

推荐答案

他们可能看起来像这样:

They could look like this:

<input type="text" name="discipline" value="6" />
<input type="text" name="marketsector" value="5" />
<input type="text" name="marketsector" value="7" />
<input type="text" name="marketsector" value="3" />
<input type="text" name="skill" value="3" />
<input type="text" name="skill" value="8" />

和这里的博客帖子你可能需要看着。和<一个href=\"http://www.hanselman.com/blog/ASPNETWireFormatForModelBindingToArraysListsCollectionsDictionaries.aspx\">similar 之一。

And here's a blog post you may take a look at. And a similar one.

这篇关于发布INT阵列控制器MVC - 什么是正确的方法签名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆