routing

Remove Trailing Slash in ASP.NET MVC 4 Route to Application Root

别说谁变了你拦得住时间么 提交于 2019-12-03 08:55:19
In my ASP.NET MVC 4 application's RouteConfig file, I have registered the following default route: routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "home", action = "index", id = UrlParameter.Optional }); Now, in my Razor views, I want to generate a URL to my application's root like that: <a href="@Url.Action("index", "home")">Home</a> The generated URL includes a trailing slash; clicking the link thus opens the page localhost/IISApplicationName /. However, I want the URL not to contain the trailing slash so that the URL is localhost/IISApplicationName . Generating

Can controller names in RESTful routes be optional?

爷,独闯天下 提交于 2019-12-03 08:54:51
With a standard map.resource routing mechanics and several nested resources the resultant routes are unnecessarily long. Consider the following route: site.org/users/pavelshved/blogs/blogging-horror/posts/12345 It's easy to create in routes.rb , and I'm sure it follows some kind of beneficial routing logic. But it's way too long and also seems like it's not intended to be human-readable. A nice improvement would be to drop controller names, so it looks like: site.org/pavelshved/blogging-horror/12345 Clear, simple, short. It may become ambiguous, but in my case I'm not going to name any user

asp.net 4 routing not working in iis 7

∥☆過路亽.° 提交于 2019-12-03 08:54:09
问题 I'm using asp.net 4 routing in one of our new product and it works fine in the development environment (Visual studio webserver). but when i moved it to remote iis for testing purpose it doesn't work. all i get is 404 error page. i tried adding the following to the web.config and still getting the error. <system.webServer> <modules runAllManagedModulesForAllRequests="true"> <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral,

Generate a URL with URL Routing in Webforms

岁酱吖の 提交于 2019-12-03 08:46:18
问题 I know in the MVC Framework, you have the Html Class to create URLs: Html.ActionLink("About us", "about", "home"); But what if you want to generate Urls in Webforms? I haven't found a really good resource on the details on generating URLs with Webforms. For example, if I'm generating routes like so: Route r = new Route("{country}/{lang}/articles/{id}/{title}", new ArticleRouteHandler("~/Forms/Article.aspx")); Route r2 = new Route("{country}/{lang}/articles/", new ArticleRouteHandler("~/Forms

Setting up ASP.Net MVC 4 Routing with custom segment variables

南楼画角 提交于 2019-12-03 08:36:36
I just began working on an application with a couple areas (basic grid master / details type system..) I'm looking into taking advantage of the nice routing features in MVC (4 specifically) and I'm "just not getting it" I presume. Currently the only route defined is the basic one: routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Account", action = "Index", id = UrlParameter.Optional } ); which is fine, it works with the areas we have defined, so I'm assuming it must know where the user is and route to the appropriate controller based contextually on the location /

How can I combine a MVC4 site and a WebAPI site under the same IIS website?

↘锁芯ラ 提交于 2019-12-03 08:34:29
I have a project (named Product.Api ) that has some controllers used for our WebAPI site. The controllers are in a namespace Product.Api.Controllers . The project also has some other helper stuff as well. This is compiled into a library. I also have another regular ASP.NET MVC4 website named Product.Web . This has Controllers (under the namespace Product.Web.Controllers ), Models and Views (in its corresponding folders). It also has a Global.asax.cs which has the routing information. When the site is created in IIS (.NET 4.5, IIS7, integrated mode, etc), I copy the Product.Api dll into the bin

how to avoid routing through local stack in Linux

自闭症网瘾萝莉.ら 提交于 2019-12-03 08:21:38
I have the following environment: 2 hosts, each with 2 Ethernet interfaces connected to eachother (like on diagram below): +---------+ +---------+ | (1)+---------------+(2) | | host1 | | host2 | | | | | | (3)+---------------+(4) | +---------+ +---------+ I would like to write client/server socket tool that will open both client and server sockets on host1. I would like client to send TCP packets through interface (1) and server to listen on interface (3), that packets will go through host2. Normally Linux stack will route this packets through local TCP/IP stack without sending those to host2.

ASP.NET MVC Routing two GUIDs

倾然丶 夕夏残阳落幕 提交于 2019-12-03 08:17:40
I have an action taking two GUIDs: public class MyActionController : Controller { //... public ActionResult MoveToTab(Guid param1, Guid param2) { //... } } I would like the following URI to map to the action: /myaction/movetotab/1/2 ...with 1 corresponding to param1 and 2 to param2. What will the route look like, and is it possible to map the arguments to parameters with a type of Guid? Yes, it is possible to map your parameters to System.Guid routes.MapRoute( "MoveToTab", "{controller}/{action}/{param1}/{param2}", new { controller = "MyAction", action = "MoveToTab", param1 = System.Guid.Empty

custom URLs using django rest framework

泪湿孤枕 提交于 2019-12-03 08:13:47
I am trying to use the django rest framework to expose my models as APIs. serializers class UserSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = User viewset class UserViewSet(viewsets.ModelViewSet): """ API end point for User details and list """ serializer_class = UserSerializer queryset = User.objects.all() routers router.register(r'users',views.UserViewSet) While this exposes /users/ and users/, I want my URLs to include a user-slug as well, something like /users/1/xyz-user-name. Has anyone solved this problem? Does this need changes in both the viewset and router

Angular Routing: Instance Creation vs Instance Activation

醉酒当歌 提交于 2019-12-03 07:54:41
问题 The Angular Routing docs mention component instance creation, component instance activation, and route activation. The docs do not explain the differences of these concepts, and when each creation/activation occurs. Questions What is the difference between instance creation and instance activation? What is the difference between instance activation and route activation? Does instance activation always occur at the same time as instance creation? In summary : It is not clear what is really