0

I have one requirement like passing multiple values in the query string in a single variable.

Id=(refine_1=cgid=womens&refine_2=c_refinementColor=Black&refine_3=price=(0..500))

Is it possible to accept value like above sample from the query string?if yes,please tel me how to achieve this?

1
  • concat the string not with "&" but with other syntax like "#" .Id=(refine_1=cgid=womens#refine_2=c_refinementColor=Black#refine_3=price=(0..500)) Commented Oct 29, 2013 at 11:41

1 Answer 1

1

You should URL encode it:

?id=(refine_1%3Dcgid%3Dwomens%26refine_2%3Dc_refinementColor%3DBlack%26refine_3%3Dprice%3D(0..500))

Now assuming that your controller action takes an id parameter:

public ActionResult SomeAction(string id)
{
    ...
}

the value of this parameter inside the action will be (refine_1=cgid=womens&refine_2=c_refinementColor=Black&refine_3=price=(0..500)).

You could bring this even a step further and write a custom model binder that will parse this value and bind it to a view model containing those properties that your controller action could take as parameter instead of a id string parameter.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.