本文介绍了自定义路由规则(例如www.app.com/project/35/search/89/edit/89)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个类似如下的路由规则:

I would like to create routing rules like the following:

www.app.com/project/35/search/89/edit/48 --->的行动是在项目控制器修改

www.app.com/project/35/search/89/edit/48 ---> action is edit in the project controller

传递的变量应该是项目#(35),搜索#(89),和编辑#(48)

The passed variables should be project# (35), search# (89), and edit#(48)

有人可以帮助我构建一个routes.MapRout()这一点。

Can someone help me structure a routes.MapRout() for this.

我要使用:

routes.MapRoute(
            "Default",
            "{controller}/{projectid}/search/{searchid}/{action}/{actionid}",
            new { controller = "Home", action = "Edit", projectid = "", actionid = "" }
        );

但是,从previous的经验,这种类型的图路线的失败......我只得到以下格式的一些工作:

But from previous experience, this type of MapRoute will fail... I've only gotten something in the following format to work:

{controller}/{action}/{variable}

谁能给我对这个有什么建议?谢谢你。

Can anyone give me any advice on this? Thanks.

推荐答案

老实说,这听起来像你需要让你的URL是这样的:

Honestly, it sounds like you need to make you URL's look like this:

www.app.com/project/35?search=89&edit=48&flag=63

这将使你喜欢更简单。

It would make your like much simpler.

这篇关于自定义路由规则(例如www.app.com/project/35/search/89/edit/89)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 03:08