maproute

Asp.net MVC 5 MapRoute for multiple routes

爱⌒轻易说出口 提交于 2021-02-09 10:56:38
问题 I have 3 routes in RouteConfig: routes.MapRoute( name: "ByGroupName", url: "catalog/{categoryname}/{groupname}", defaults: new { controller = "Catalog", action = "Catalog" } ); routes.MapRoute( name: "ByCatName", url: "catalog/{categoryname}", defaults: new { controller = "Catalog", action = "Catalog" } ); routes.MapRoute( name: "ByBrandId", url: "catalog/brand/{brandId}", defaults: new { controller = "Catalog", action = "Catalog" } ); and this is my action controller receiving parameters:

MVC - Route with querystring

风流意气都作罢 提交于 2020-01-15 05:26:07
问题 After following this MVC 4 tutorial series I was trying some of the stuff myself. I started by trying to make the searchfilter url friendly. The following code is what I'm using at the moment: Global.asax public static void RegisterRoutes(RouteCollection routes) { routes.MapRoute( name: "MovieSearch", url: "Movies/SearchIndex/{movieGenre}/{searchString}", defaults: new { controller = "Movies", action = "SearchIndex", movieGenre = UrlParameter.Optional, searchString = UrlParameter.Optional } )

Registering Multiple Routes in MVC asp.net

南楼画角 提交于 2020-01-02 11:27:17
问题 I want to do make several map route in MVC that both like be same. localhost:1010/abcd/home/index localhost:1010/home/index/abcd id=abcd controller=home action=index I used bellow code but it doesn't work public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "ShoppingManagment", "{id}/{controller}/{action}", new { controller = "ShoppingManagment", action = "ShoppingManagment", id = UrlParameter.Optional }); routes

Creating an ActionLink and MapRoute that there is a constant name in it

徘徊边缘 提交于 2019-12-25 06:14:25
问题 In my Asp.net MVC 5 (C#) project I want to create some links by @Html.ActionLink or every you know is better like: /Tags/Linq /Tags/SqlServer /Tags/MVC That Tags is constant name and after that in the URL is tag name.For example like ScottGu's Blog In addition I want to pass a parameter such as Id but I don't want to show in the URL. How can I do it? And how should I write a suitable MapRoute for it? Please help me. 回答1: For example (don't forget to write it before default route): routes

How to declare a parameter as prefix on OData

北城以北 提交于 2019-12-24 14:03:55
问题 Using a normal ApiController in WebApi, I made the following code to define a dynamic map route template for every ApiControllers: config.Routes.MapHttpRoute( name: "Sample", routeTemplate: "{sessionId}/{controller}" ); I want to achieve a similar behaviour but for every ODataController. I've tried the following code, but it doesn't work: config.MapODataServiceRoute( routeName: "HSODataRoute", routePrefix: "{sessionId}/", model: GetEdmModel()); Any idea how this is made in OData? I'm kinda

Asp.net MVC and redirect to External site

☆樱花仙子☆ 提交于 2019-12-23 03:34:09
问题 I have created a mvc application, its working fine, now I want to add some route based on xml, I don't want to create action based on that, that will work on fly. i.e. www.lmenaria.com/site1 this will redirect to www.site1.com www.lmenaria.com/site2 this will redirect to www.site2.com www.lmenaria.com/site3... this will redirect to www.site3.com No action Site1, site2, site3 lmenaric.om, so what will be the route and how can I redirect to external site. 回答1: You can do this on controller with

MVC routing static file

99封情书 提交于 2019-12-22 07:47:24
问题 I am working with a legacy swf file that is looking in the controller/action routing for a static route. For example, it is trying to download the file http://localhost:59801/Resource/Details/ClearExternalPlaySeekMute.swf When the file exists in the root directory: http://localhost:59801/ClearExternalPlaySeekMute.swf Can I use MapRoute to map this URL to the root directory? 回答1: You could use the url rewrite module in IIS. Once you install it simply add the following rewrite rule: <system

MVC routing static file

本秂侑毒 提交于 2019-12-22 07:47:05
问题 I am working with a legacy swf file that is looking in the controller/action routing for a static route. For example, it is trying to download the file http://localhost:59801/Resource/Details/ClearExternalPlaySeekMute.swf When the file exists in the root directory: http://localhost:59801/ClearExternalPlaySeekMute.swf Can I use MapRoute to map this URL to the root directory? 回答1: You could use the url rewrite module in IIS. Once you install it simply add the following rewrite rule: <system

How to draw routes on maps in ios 6?

白昼怎懂夜的黑 提交于 2019-12-21 21:06:06
问题 I want to show maps & draw routes on maps. My application supports for ios 4 plus. So how should i use maps to work on ios 6 as well as before. Also i want to know sholud i use custom mapview in my app to display maps & routes or should i use [[UIApplication sharedApplication] openURL:] I have never user MapKits . So please provide if any tutorial. Also let me know if there are any rd party libraries that can be used. 回答1: If you don't want an in-app map. Use the following: NSString

C# MVC 4 ControllerName attribute

故事扮演 提交于 2019-12-19 17:48:05
问题 I'm working on providing friendly names for my MVC 4 controllers and I want to do something like the [ActionName="My-Friendly-Name"] style, but for the whole controller. I couldn't find any information about such an attribute, so how would I go about doing that? Also, will I need to add a new MapRoute to handle it? EDIT: For example, I'd like to route the following url: http://mysite.com/my-reports/Details/5 be routed to the following controller: [ControllerClass="my-reports"] // This