English 中文(简体)
随机参数
原标题:mvc route random number of parameters

我试图修建一条通往特定产品页的路线。

该产品属于一类。 类别中也可能有类别。 我正试图建造卢爱阵这样的建筑。

2. 现场/产品/类别/类别/产品

类别数量可以改变,但最后参数永远是产品名称。

是否有办法为此修建一条道路?

最佳回答

A solution exactly for you

过去,我面临同样的问题,这个问题与其他人在此向你们提供什么不同。 多数解决办法将讨论 副渔获物-all参数。 在你的情况下,这意味着你必须把产品 par掉。 手册。 由于总捕获参数可能只是路线定义的最后参数。

Catch-all anywhere in the route

如果你仔细地认为,你可以实际认识到,只要你有其他所有部分在场,就可以在路线的任何地点实际确定所有参数。 因此,我撰写了这些路线班子,这些班子完全如此,并在重型交通网站上成功运行。

我的博客职位掌握了有关该职位的所有信息,以及所有将<>解决你的问题的法典::

rel=“nofollow”> Customs Asp.net MVC路段,在URL任何地方都有渔获部分。

This makes it possible for you to define your route as:

products/{*categories}/{productId}

If you think of the catch-all parameter even further you could also get to the point that a single route definition could have several catch-all parameters as long as at least one segment between them is static. But my class isn t able to do this, because your scenario with just one arbitrary segment set is much more common.

问题回答

暂无回答




相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

热门标签