0

I have a simple model.

class MyModel
{
    public int id{get;set;}
    public IEnumerable<int> params{get;set;}
}

my action method is declared as:

public ViewResult Index(int id, IEnumerable<long> params)

and have a simple code on template with razor engine:

 @Html.BuildUrlFromExpression((ShareController c) => c.Index(Model.id, Model.params));

the thing RouteCollection.GetVirtualPath - this method returns an incorrect URL as result i have url fir example @Url.Action("Index","Default",new {id=1, params = new long[]{11,33}}); get some value

/Default/Index/49?params=System.Int64%5B%5D;

it seems rather obvious fact that the construction of the address must correctly understand what type it is passed. I would want that the BuildUrlFromExpression gave the correct value.

/Default/Index/49?params=23&params=45

I have some work solution:

var rv = new RouteValueDictionary();
rv.Add("param[0]", 11);
rv.Add("param[1]", 33);
rv.Add("id", Model.CurrInFolderNum);
Url.Action("Index","default",rv)

but it works through the transmission of some number of parameters! I wish that would have been transferred to the array. I think the answer somewhere on the surface.

4

0 回答 0