asp.net-mvc-routing

Use MVC routing to alias a controller

血红的双手。 提交于 2019-12-01 16:09:58
I have a controller called InstallationController , and a fancy report representation of an installation called a Rate Card , but the end user insists on calling installations themselves Rate Cards . I would like him to see the URL http://site/RateCard/Edit/3 , where this gets routed actually as http://site/Installation/Edit/3 . How can I do this in MVC 3 RC2? A couple of options are, you can either rename the controller to RateCardController , or add a new route that directs to the Installation controller, like: routes.MapRoute( "RateCard", // Route name "RateCard/{action}/{id}", // URL with

ASP.Net MVC - Trapping certain URL's to do 301 Redirect

孤人 提交于 2019-12-01 14:57:14
I am moving from an old site design to a new design with new URL's. All previous page names were static files called PageXX.html, PageX.html, Index.html - where X is a number. My site is now dynamic but I want to trap for those 3 incoming url's and then try and redirect to a certain new page (301 Redirect) else send them to the home page. Do I do all of this in Global.asax or do I just trap those Url's in Global.asax and then route it to a Action and do a 301 Redirect in the Action? Any code examples would help a lot! Thanks EDIT: I think what needs to be done is trap the routes in Global.asax

Use MVC routing to alias a controller

ε祈祈猫儿з 提交于 2019-12-01 14:26:16
问题 I have a controller called InstallationController , and a fancy report representation of an installation called a Rate Card , but the end user insists on calling installations themselves Rate Cards . I would like him to see the URL http://site/RateCard/Edit/3, where this gets routed actually as http://site/Installation/Edit/3. How can I do this in MVC 3 RC2? 回答1: A couple of options are, you can either rename the controller to RateCardController , or add a new route that directs to the

Tenant-specific routes for dynamically loaded modules

南笙酒味 提交于 2019-12-01 14:04:50
I am using ASP.NET MVC to develop an application framework. Essentially, the end goal is to be able to log into an admin interface, create a new tenant with custom settings, enable the modules they want (blog, shopping basket, etc)... job done - satisfied customer with new website. I'm not using separate applications because there will be a lot of shared code and it would be easier to maintain this way, and also because it would be pretty easy to bring a new, identical node online at peak times. Depending on what modules are loaded for the tenant, different routes are applicable for each

Tenant-specific routes for dynamically loaded modules

为君一笑 提交于 2019-12-01 12:59:42
问题 I am using ASP.NET MVC to develop an application framework. Essentially, the end goal is to be able to log into an admin interface, create a new tenant with custom settings, enable the modules they want (blog, shopping basket, etc)... job done - satisfied customer with new website. I'm not using separate applications because there will be a lot of shared code and it would be easier to maintain this way, and also because it would be pretty easy to bring a new, identical node online at peak

mvc how to change default route

℡╲_俬逩灬. 提交于 2019-12-01 12:50:56
问题 I'm going through the Pro Asp.net mvc3 framework book. I wanting to change the default route so that I can have a different home page. I've added a new controller called Pages and a view called Home. This is what I'm wanting as my home page. I've tried adding this to my global.asax.cs routes.MapRoute("MyRoute", "{controller}/{action}/{id}", new { controller = "Pages", action = "Home", id = "DefautId" }); This changes the default page, but it screws up the categories public static void

ASP.Net MVC - Trapping certain URL's to do 301 Redirect

谁都会走 提交于 2019-12-01 12:39:28
问题 I am moving from an old site design to a new design with new URL's. All previous page names were static files called PageXX.html, PageX.html, Index.html - where X is a number. My site is now dynamic but I want to trap for those 3 incoming url's and then try and redirect to a certain new page (301 Redirect) else send them to the home page. Do I do all of this in Global.asax or do I just trap those Url's in Global.asax and then route it to a Action and do a 301 Redirect in the Action? Any code

Attribute vs Conventional Routing

我们两清 提交于 2019-12-01 11:39:25
Q1: So this article says attribute routing is more favourable than conventional routing for api versioning. It's not clear to me the reasons behind such claim because to me in order to support these: /api/v1/products /api/v2/products all you need to do is to define two routes: routes.MapHttpRoute("V1", "api/v1/products", new {controller = "V1Controller", action = "ListProducts"}); routes.MapHttpRoute("V2", "api/v2/products", new {controller = "V2Controller", action = "ListProducts"}); Can something share some insight? Q2: this article says one issue with conventional routing is the order of

How to Route /About to /Home/About

浪尽此生 提交于 2019-12-01 11:29:52
I am just getting started with ASP.NET MVC and it's great! However, I don't quite understand setting up routes. How do I route ~/About to ~/Home/About? /Views/Home/About.aspx I would like to be able to access it with /Home/About or just /About If you want to explicity setup a route for it, you can do something like this: routes.MapRoute( "AboutRoute", "About", new { controller = "Home", action = "About" } // Parameter defaults ); I think thats what you want to do? I.e. have /About handled by the home controller? The default route (as below) handles /Home/About routes.MapRoute( "Default", //

ASP.NET MVC 2 RC2 Routing - How to clear low-level values when using ActionLink to refer to a higher level?

為{幸葍}努か 提交于 2019-12-01 11:16:33
[NOTE: I'm using ASP.NET MVC2 RC2.] I have URLs like this: /customers/123/orders/456/items/index /customers/123/orders/456/items/789/edit My routing table lists the most-specific routes first, so I've got: // customers/123/orders/456/items/789/edit routes.MapRoute( "item", // Route name "customers/{customerId}/orders/{orderId}/items/{itemId}/{action}", // URL with parameters new { controller = "Items", action = "Details" }, // Parameter defaults new { customerId = @"\d+", orderId = @"\d+", itemId = @"\d+" } // Constraints ); // customers/123/orders/456/items/index routes.MapRoute( "items", //