简体   繁体   中英

How can I have a none to one or many parameter list in MVC

I want to capture requests like these three:

http://localhost:55835/Home/Print?storeName=MyStore    
http://localhost:55835/Home/Print?storeName=MyStore&p.0=Dogs&p.1=Cats    
http://localhost:55835/Home/Print?storeName=MyStore&p.0=Dogs&p.1=Cats&p.2=Mice    

I would like something not hard coded but I don't know what type to use for the set of p.* parameters?

public ActionResult Print(string storeName, string[] p)
{
    return View();
}

不知道是否可以选择更改URL格式,但是可以这样做,但是可以保持操作方法不变:

http://localhost:55835/Home/Print?storeName=MyStore&p=Dogs&p=Cats&p=Mice    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM