routing

asp.net mvc routing: how to use default action but non-default parameter?

孤人 提交于 2020-01-12 12:49:26
问题 I'm rewriting the question, as the answers so far show me that I have not defined it good enough. I'll leave the original question for reference below. When you set up your routing you can specify defaults for different url/route parts. Let's consider example that VS wizard generates: routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "DefaultPage", action = "Index", id = UrlParameter.Optional } // Parameter defaults In this

custom URLs using django rest framework

我们两清 提交于 2020-01-12 05:50:11
问题 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

What is the best method to achieve dynamic URL Rewriting in ASP.Net?

大兔子大兔子 提交于 2020-01-12 03:55:52
问题 I'm currently using Intelligencia.UrlRewriter does anyone have better suggestions? 回答1: System.Web.Routing is part of .NET 3.5 SP1 and you can use it both for your ASP.NET WebForm-application and your MVC-application. The official ASP.NET site has a good QuickStart Tutorial on System.Web.Routing. 回答2: ISAPI_Rewrite is also a good generic solution - works not only with ASP.NET but with any other system. 回答3: An alternative approach to consider is URL routing. This is not the same as rewriting

on html.actionlink click go to previous page

放肆的年华 提交于 2020-01-11 17:09:28
问题 Currently in a link Customer/businessunit/RepresentativeDetails?RepresentativeId=cd3a7263-78f7-41bd-9eb0-12b30bc1059a I have following code for view @Html.ActionLink("Back to List", "Index") which takes me to this link customer/businessunit/index but rather that going to index page I want to go to previous page when the actionlink is clicked, which is Customer/businessunit/BusinessUnitDetails/c4a86253-a287-441e-b83d-71fbb6a588bc How do I create an actionlink that directs me to previous page?

PHP Routing - stylesheets have no effect

时光毁灭记忆、已成空白 提交于 2020-01-11 14:23:08
问题 I have created a basic Routing-system in PHP. The url is split into an array, so that i can decide what to show depending on the URL (ex: www.domain.com/page/option/param). So in my index.php I've defined a div for header, content and footer, and the /page/ determines which file to include in the content-div. The routing works, and the HTML is loaded, but the stylesheet doesn't seem to be. Neither does it work when I <link> the stylesheet directly in the file (and supposedly it's possible to

PHP Routing - stylesheets have no effect

旧城冷巷雨未停 提交于 2020-01-11 14:23:07
问题 I have created a basic Routing-system in PHP. The url is split into an array, so that i can decide what to show depending on the URL (ex: www.domain.com/page/option/param). So in my index.php I've defined a div for header, content and footer, and the /page/ determines which file to include in the content-div. The routing works, and the HTML is loaded, but the stylesheet doesn't seem to be. Neither does it work when I <link> the stylesheet directly in the file (and supposedly it's possible to

Dynamically create query Params in Angular 2

馋奶兔 提交于 2020-01-11 08:37:05
问题 i want to achieve that the queryParams can be dynmamically passed it. For now i can set the values of the params dynamically, but not the keys Here is my Code onItemClick(item: FilterItem, group: FilterGroup, i: number) { let navigationExtras: NavigationExtras = { queryParams: { name : group.items[i].param } }; this.router.navigate(['/search'], navigationExtras); } I cannot put instead of "name" my group.name which is a string. I tried this: queryParams: { group.name: group.items[i].param }

Regex in Route attribute - RESTful API ASP.NET Web API

◇◆丶佛笑我妖孽 提交于 2020-01-11 07:41:08
问题 I've got a problem with regular expressions in Route attribute. I'd like to create RESTful API, where you can specify start date and end date in URL to filter results. What I've done till now is: [HttpGet] [Route("date/{startDate:datetime:regex(\\d{4}-\\d{2}-\\d{2})}/{*endDate:datetime:regex(\\d{4}-\\d{2}-\\d{2})}")] [Route("date/{startDate:datetime:regex(\\d{4}/\\d{2}/\\d{2})}/{*endDate:datetime:regex(\\d{4}/\\d{2}/\\d{2})}")] public IEnumerable<Recommendation> GetRecommendationByDate

Controller method not found - laravel 4

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-11 05:00:09
问题 I have this message whine trying to run any controller Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException Controller method not found. I have this Code in my Route file Route::controller("/","HomeController"); Route::controller("users","UsersController"); and this code in my Controller <?php class UsersController extends BaseController { protected $layout = "layouts.main"; public function __construct() { $this->beforeFilter('csrf', array('on' => 'post')); $this->beforeFilter

ArgumentError: wrong number of arguments (1 for 2)

不羁岁月 提交于 2020-01-11 04:46:13
问题 I'm very new to Rails, MVC, and CRUD, and I'm trying to use the update method to change the amount of votes on a post. I have the following code in my Posts Controller update method: def update @post = Post.find(params[:id]) if params[:vote] == 'up' @post.update_column(:ups => @post[:ups] + 1) elsif params[:vote] == 'down' @post.update_column(:downs => @post[:downs] + 1) end flash[:notice] = "Thanks for voting! This helps us determine important issues in our schools." redirect_to 'Posts#index