从路由的数据库路径hiearchical与ASP.Net MVC [英] Routing an hiearchical path from DB with ASP.Net MVC

查看:126
本文介绍了从路由的数据库路径hiearchical与ASP.Net MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是有可能的路线如下映射从数据库关系的hiearchical路径

is it possible to route an hiearchical path to map an relation from the database as follows:

可以说我有一个元组/实体页上的一个MTM关系到页(它selfe),我希望能够在每个页面的塞价值结合起来,找到一个合适的页面,像这样

Lets say I have an tuple/entity "page" with an m-t-m relation to a "page" (it selfe) and I want to be able to combine the slug-value of each page to find an appropriate page, like so:

mydomain.com/firstpage/secondpage/thirdpage

,其中第一页,secondpage和thirdpage类型为页,并在第二页第三页引用等。

where firstpage, secondpage and thirdpage is of type "page" and the third page references to the second page etc.

你将如何与ASP.Net MVC路由实现这个?

How would you implement this with ASP.Net MVC Routing?

推荐答案

好吧,我想解决它!

我发现有一个*(包罗万象参数)可路由时使用。

I found out that there is a * (catch-all parameter) that can be used when routing.

例如:

routes.MapRoute(
    "Pages",
    "{*pageQuery}",
    new { controller = "Page", action = "GetPage" }
);

然后在我的控制,我可以使用常规的前pressions或简单拆分为解决塞的各个部分。 :)

Then in my controller I can use regular expressions or a simple split to resolve each part of the slug. :)

这篇关于从路由的数据库路径hiearchical与ASP.Net MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆