Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 从作用中的url解析动态参数_Asp.net Mvc 3_Design Patterns_Model Binding_Specifications - Fatal编程技术网

Asp.net mvc 3 从作用中的url解析动态参数

Asp.net mvc 3 从作用中的url解析动态参数,asp.net-mvc-3,design-patterns,model-binding,specifications,Asp.net Mvc 3,Design Patterns,Model Binding,Specifications,在测试项目中,我尝试学习规范模式以及如何在在线商店中使用它。按类别分组的产品规格,例如:颜色(蓝色、深蓝色等)、高度(100厘米、200厘米等)。根据产品中选定的类别添加到产品中的规格。在我读过的所有文章中,动作中的规范称为参数。但是,如果在我的测试项目中动态添加规范,我不知道如何实现它。例如,我有以下控制器操作: public ActionResult Products(string category, string[] specificationNameValueP

在测试项目中,我尝试学习规范模式以及如何在在线商店中使用它。按类别分组的产品规格,例如:颜色(蓝色、深蓝色等)、高度(100厘米、200厘米等)。根据产品中选定的类别添加到产品中的规格。在我读过的所有文章中,动作中的规范称为参数。但是,如果在我的测试项目中动态添加规范,我不知道如何实现它。例如,我有以下控制器操作:

    public ActionResult Products(string category, 
        string[] specificationNameValuePairs, int page = 1, int pageSize = 9, 
        string order = "Position, Name", string ordertype = "asc")
    {
    ...
    }

如何在此操作中绑定specificationNameValuePairs?或者我必须重新设计我的项目,使用静态规范,并为每个规范类别创建绑定模型?

您必须了解Url.Action方法。请检查下面的链接,它可能会有所帮助