问题标签 [maproute]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
81 浏览

asp.net - ASP.Net mvc2 url 格式问题

在我的 mvc2 项目中,一些 URL 显示在浏览器中,如下所示,

本地主机:53289/Paper/ViewAgendaPaper?MeetingId=186&type=2&RefId=186

但我更喜欢看起来像这样

本地主机:53289/Paper/ViewAgendaPaper

在我的 Global.asax 中,

如何隐藏 URL 中的 id 字段。请给我一些想法。谢谢你。

0 投票
1 回答
313 浏览

asp.net-mvc - 个性化asp.net MVC路由尺

我不完全了解如何在 asp.net mvc 中使用路由。我将视图和控制器组织在 2 个主要文件夹中:前台和后台。现在我想在后台以这种方式构建 url 的操作:frontoffice/controller/action/parameters 文件夹frontoffice中的操作以经典方式:controller/action/parameter

我写了这些规则,但它们不正确

这样,frontoffice 中的所有操作都使用“backoffice”构建 url。我该怎么做?

0 投票
1 回答
262 浏览

asp.net-mvc-3 - mvc3 控制器不工作 - 路径映射错误

这是我的代码:

对于第一个链接,如果我转到:localhost/song localhost/date 等它会很好地打开主控制器下的所有链接。

但是对于第二个 maproute:localhost/admin localhost/admin/index - 这些链接不起作用?谁能告诉我我做错了什么?

0 投票
4 回答
12222 浏览

c# - C# MVC 4 ControllerName 属性

我正在为我的 MVC 4 控制器提供友好的名称,我想做一些类似[ActionName="My-Friendly-Name"]风格的事情,但是对于整个控制器。

我找不到有关此类属性的任何信息,那么我该怎么做呢?另外,我需要添加一个新的 MapRoute 来处理它吗?

编辑:

例如,我想路由以下网址:

被路由到以下控制器:

}

0 投票
1 回答
70 浏览

asp.net-mvc-2 - 指定 RouteValue 以匹配模式 /id

我正在使用 asp.net mvc2,如果用户输入 foo.com/123,我希望我的网站显示详细信息(123 个)。我应该为此指定的路线值是什么,以什么顺序?我试过了

但我得到一个 404。

任何帮助表示赞赏。

0 投票
0 回答
1598 浏览

asp.net-mvc - MVC Routing to use optional subfolder (like a set of virtual directories)

Here's the problem that I have been tearing hair out over since Friday.

I have a single MVC application that serves several different subgroups for a single client. For branding and for some style elements, the Url's need to be formatted like: www.site.com/Login www.site.com/Client1/Login www.site.com/Client2/Login www.site.com/Client3/Login and so on.

We would also like to maintain this structure, moving onto www.site.com/Client1/News, etc.

Static routing is off the table. Even a tool to generate them. The site will have X pages with a unique route for Y clients, and I shudder to think about the performance. And because of teh dynamic nature, creating virtual dirs on the fly is not a route I want to travel down.

At first the solution seemed trivial. I tried two test solutions.

The first derived from CustomRouteBase and was able to determine the correct route in the overridden GetRouteData method and then generate the correct Url using GetVirtualPath. The second solution used constraints to see if a client was in the pattern and route accordingly. Both would hit the correct controllers and generate correct links.

Then I added areas (this is just a prototype, but the real site uses areas).

Both solutions failed. The areas were registered properly and worked as they typically should. But with the first solution, I could not find a way to override GetVirtualPath for area registration. I know there is an extension methods off the Area class, but this doesn't fit what I need.

I also tried using a constraint, but the "client" part of the Url was not being added to any of the action links to the areas and trying to route to a controller using a constraint gave me the good old view not found error (searching from the root even though I had specified the area in the route).

So my first question is am I going about this the wrong way? If there is a better way to accomplish this, I am all eras. If not, then how do I manage areas?

I could put some code up here, but it all works for what I want it to do. I'm sort of lost at how to approach the area issue. But unfortunately as always I inherited this project 3 months before launch and my team simply doesn't have the resources to restructure the site without them.

@Max... I tried something similar, but thh areas still would not display their links correctly when in www.site.com/Client1... This is from prototype 6, I tried a few different ways.

Here is another way I tried to tackle it. Please don't crack on the implementation, it's just a POC. The problem here was that Areas are not part of RouteBase, so I can't modify the virtual paths for them. So every action link, etc, get's rendered correctly and all works well as long as the action is not in an area.

Thanks Liam... that's similar to how our view engine is customized, to read from a "plugins" folder first for view overrides. But the problem is a little different here. This is one client that already has a site with view overrides, but in turn has multiple clients of their own. The behavior here is just to control style sheets, logos, etc. After a user is logged in, I can identify what the style and branding should be, but for landing pages the client wants to use a(n) url like "www.site.com/Client1" to identify this. I've given up and written a handler that just turns the request into www.site.com/?client=client1 so I can handle landing page styling, but it would be so much nicer to leave the url as www.ste.com/Client1/login, etc. This is a conversion from a classic asp app that used vdirs to host different directories prior to this. Because of the number of potential clients (100's), static routing gets heavy. My solutions all work to a point... it's the areas that are causing all the problems. If I could just find a way to remap their virtual paths dynamically like I can with the routes I create in RouteBase, I would be in business... I think.

0 投票
2 回答
6596 浏览

c#-4.0 - 如何在 MVC 中使用路由来实现 SEO 友好 URL

通常,我们的 global.asax 文件中有以下示例代码。所以,我的问题是我们如何拥有多个 MapRoute 以及如何使用它们???

我想要这样的网址:

我想要这样的东西,但我不明白如何使用这个路由,以便我可以获得 SEO 友好的 URL:

提前致谢。

0 投票
3 回答
157 浏览

c# - 关于 ASP.NET MVC 路由

比如我得到一个过滤器模型:

并且有一个 SearchController 动作,例如:

所以问题是。如何配置 URL

谢谢您的帮助

0 投票
1 回答
240 浏览

asp.net-mvc - 混合 Web 表单/MVC 应用程序中的 MapRoute

我有一个较旧的网络表单应用程序,现在我正在尝试使用 MVC 添加新页面。除了一件事之外,这一切似乎都运行良好:应用程序的默认页面 ( login.aspx) 是一个 Web 表单。当用户点击链接时,站点不会www.mysite.com打开,而是www.mysite.com/login.aspx立即转到 global.aspx 中指定的路由

那么,问题是如何制作login.aspx默认页面?
是否可以不转换 login.aspx为 MVC 视图并添加相应的控制器?

0 投票
2 回答
9277 浏览

iphone - 如何在 iOS 6 中的地图上绘制路线?

我想在地图上显示地图并绘制路线。我的应用程序支持 ios 4 plus。那么我应该如何使用地图在 ios 6 上和以前一样工作。我也想知道我应该在我的应用程序中使用自定义地图视图来显示地图和路线还是应该使用

我从来没有用户MapKits。所以请提供任何教程。也让我知道是否有任何可以使用的 rd 方库。