url-routing

ASP.NET MVC - MapRoute versus routes.Add (and 404s)

别等时光非礼了梦想. 提交于 2019-12-20 09:53:37
问题 I'm just getting started with ASP.NET MVC. What is the difference between MapRoute and routes.Add ? Should I just be using MapRoute? Can I map multiple routes? Which "maps" take precedence... those you called first or last? I'd like to be able to do something similiar to the StackOverflow does for users. But I would like the URL to fit this pattern: "User/{domain}/{username}" to be routed to a UserController and for all other requests to do the typical ASP.NET MVC routing. ex: routes.MapRoute

Pass URL to as $routeParam in AngularJS app

此生再无相见时 提交于 2019-12-20 09:48:37
问题 How can I pass actual URL (with slashes, commas, etc.) as a $routeParam to AngularJS App? this will work: http://paprikka.github.io/le-bat/#/preview/asdadasda this won't: http://paprikka.github.io/le-bat/#/preview/http://page.com neither will this: http://paprikka.github.io/le-bat/#/preview/http%3A%2F%2Fpage.com or this: http://paprikka.github.io/le-bat/#/preview/?url=http%3A%2F%2Fpage.com Details AngularJS routing mechanism by its design does not allow to pass strings with slashes as query

ASP.NET MVC3 routing REST services to controller

别说谁变了你拦得住时间么 提交于 2019-12-20 09:25:13
问题 I want to route REST service url in the following way: /User/Rest/ -> UserRestController.Index() /User/Rest/Get -> UserRestController.Get() /User/ -> UserController.Index() /User/Get -> UserController.Get() So basically I'm making a hardcoded exception for Rest in the url. I'm not very familiar with MVC routing. So what would be a good way to achieve this? 回答1: Wherever you register your routes, commonly in global.ascx routes.MapRoute( "post-object", "{controller}", new {controller = "Home",

Correct optional route parameters on browsing url

我们两清 提交于 2019-12-20 07:49:06
问题 I am working on Ecommerce project (Asp.Net Mvc3). My routes for product and categories are mentioned below routes.MapLocalizedRoute( "Product", "p/{productId}/{SeName}", new { controller = "Catalog", action = "Product", SeName = UrlParameter.Optional }, ); routes.MapLocalizedRoute( "Product", "c/{categoryId}/{SeName}", new { controller = "Catalog", action = "Category", SeName = UrlParameter.Optional }, ); When use browse url http://mysite.in/p/123/my-product it redirects to correct product

Bug in implemented tagging system

喜欢而已 提交于 2019-12-20 07:38:02
问题 I have followed Hartl's tutorial to make a ToDoList with a tagging system, also with the help of this word guide and video. However, I do not really understand how the tagging system works in terms of the filtering, so I just copied it and improvised. Now I have a problem with my filtering system as now it just redirects to a brand new page that contains all tasks including those that doesn't have the clicked tag. Before After Here is the updated log on my command line after inserting puts

Cakephp 3.1 - How to redirect based on query string values?

落爺英雄遲暮 提交于 2019-12-20 06:15:44
问题 We recently updated our site from pure php to cakephp 3 and having trouble redirecting urls that have params to a new url. For example this redirect works fine $routes->redirect('/webcast.php', '/webcast', ['status' => 302]); But if there's parameters, it doesn't work $routes->redirect('/webcast.php?id=100', '/webcast', ['status' => 302]); Any ideas? Thanks. 回答1: The router doesn't support matching on query strings, the URL passed to the router when checking for a matching route won't have

How to specify url mappings in ASP.NET 4.0 when parameters are involved?

冷暖自知 提交于 2019-12-20 04:39:07
问题 The problem I have a web site with some articles inside. Articles are accessed using a database writing results on a single page. When a certain article is to be accessed, I need the article-id and I only need to get to the page: http://www.mysite/Articles.aspx?a={article-id} . This is nice but not really friendly and not scalable. What I want to do is to redirect every url in the form: http://www.mysite/articles/{article-id} to the page http://www.mysite/Articles.aspx?a={article-id} . I know

Current URL in ASPCore Middleware?

五迷三道 提交于 2019-12-20 02:47:33
问题 Is there a way I can access the current Requested URL in ASPCore 2.0 Middleware? Is there something I can Inject? 回答1: HttpContext object will be passed to the Invoke method of your middleware. You can access the Request property on that. You can use the GetDisplayUrl extension method or GetEncodedUrl extension method. public Task Invoke(HttpContext context) { var url1 =context.Request.GetDisplayUrl(); var url2 = context.Request.GetEncodedUrl(); // Call the next delegate/middleware in the

Custom url in ruby on rails

无人久伴 提交于 2019-12-20 02:29:28
问题 I know rails uses the controller action style urls like www.myapp.com/home/index for example I would like to have a url like this on my rails app, www.myapp.com/my_page_here is this possible and if so how would I go about this? 回答1: You just use a get outside of any resources or namespace block in your routes.rb file: get 'my_page_here ', :to => 'home#index' Assuming you are using Rails 3+, do NOT use match . It can be dangerous, because if a page accepts data from a form, it should take POST

MVC3 and Rewrites

别等时光非礼了梦想. 提交于 2019-12-20 02:06:33
问题 I'm writing an MVC3 application that will need to make use of URL rewriting in the form of http://[server]/[City]-[State]/[some term]/ . As I understand it, MVC3 contains a routing engine that uses {controler}/{action}/{id} which is defined in the Global.asax file: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home",