routing

ASP.NET MVC routing conflict - null value for input variable

不羁的心 提交于 2019-12-05 07:57:15
I'm at a loss as to why my routes are conflicting. I have these in my Global.asax file: routes.MapRoute( "CustomerView", "{controller}/{action}/{username}", new { controller = "Home", action = "Index", username = "" } ); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "0" } ); So far everything has worked fine except when I created a controller action like so: public ActionResult MyAction(int id) { //Do stuff here return View(); } When I try viewing it through http://mydomain/MyController/MyAction/5 I get: Server Error in '/'

Outputcache doesn't work with routing

妖精的绣舞 提交于 2019-12-05 07:25:17
问题 I'm using routing from System.Web.Routing without MVC in a standard ASP.Net Web Application Project application. This is mostly done to get neater urls in the portal we are developing (instead of ~/default.aspx?contentid=123 we have ~/{contentsubject}. The portal is not authorized and all info is in the url so in a caching scenario we can cache complete pages. When I tried to enable output caching I noticed that no caching was done. It seems that the outputcache page directive is completely

ASP.NET 4.0 Routing and Subfolders

谁都会走 提交于 2019-12-05 07:01:45
问题 I have a folder structure like this: www.mysite.com/About/About.aspx I have a link in a user control like this: <a href="~/About/About" id="aboutLink" title="About" runat="server">About</a> And in my RegisterRoutes() method, I have this: routes.MapPageRoute("", "About/About/", "~/About/About.aspx"); It works but produces the following URL: www.mysite.com/About/About What I would like is this: www.mysite.com/About Is this possible with out-of-the-box 4.0 routing? UPDATE 2 - 05-14-2010:

Alternative places to register routes to global.asax

喜欢而已 提交于 2019-12-05 06:36:47
It's most common practice to register routes in Application_Start event within global.asax.cs/vb file. But you need to have access to this file to do so. Fine. I either don't have or don't want to. I'm trying to integrate Asp.net MVC application into a Sharepoint 2010 site and don't want to create my custom global application class that would also register routes for me and change the Sharepoint's Global.asax file and put a different class definition in it. My application wouldn't be accepted because I would be doing unsupported things to Sharepoint. I was wondering if it was possible to

Ruby on Rails: Routing for a tree hierarchy of places

纵然是瞬间 提交于 2019-12-05 06:20:56
问题 So we've got a legacy system that tracks places with IDs like "Europe/France/Paris", and I'm building a Rails facade to turn this into URLs like http:// foobar/places/Europe/France/Paris. This requirement is not negotiable, the number of possible levels in unlimited, and we can't escape the slashes. Setting up routes.rb for http://foobar/places/Europe is trivial: map.resources :places ...but http:// foobar/places/Europe/France complains "No action responded to Europe". I tried: map.connect '

Django '/' only homepage url error

天涯浪子 提交于 2019-12-05 05:36:39
I am using Django 2.0 and now I have no idea how to make an 'empty' url for the homepage. Meaning, I want it to route for web.com/ or web.com . I tried this code but it does not work: urlpatterns = [ path('admin/', admin.site.urls), path('/', include('post.urls')) ] ...and post.urls urlpatterns = [ path('', views.index, name='index') ] And the error I get when I make a request to localhost:8000 : Request URL: http://localhost:8000/ Using the URLconf defined in myblog.urls, Django tried these URL patterns, in this order: admin/ / The empty path didn't match any of these. I did sort of find a

Symfony2: URLs with trailing slash and an optional parameter

岁酱吖の 提交于 2019-12-05 04:57:49
I want all URLs in my application to have a trailing slash. I have the following route in my route.yml: foo_route: pattern: /foo/{page}/ defaults: { _controller: FooBundle:Foo:list, page: 1 } requirements: page: \d+ Requests to '/foo/1/' work fine, however requests to '/foo/' are not matched because of the trailing slash in the URL pattern. How can I define routes with trailing slashes and an optional parameter? I am aware I can define 2 different routes for the two cases, but I want to avoid that. In a separate but related case, you can match the following three patterns: /foo /foo/ /foo/page

alias url with sinatra / padrino

让人想犯罪 __ 提交于 2019-12-05 04:57:30
问题 I've this and it works get :about, :map => '/about_us' do render :erb, "<%= 'foo' %>" end get '/:slug' do redirect "/about_us" # <-- end Is possible to do in some way "render" instead of "redirect"? or something like render 'posts/1' 回答1: get :about, :map => '/about_us' do render :erb, "<%= 'foo' %>" end get '/:slug' do call env.merge('PATH_INFO' => '/about_us') end 来源: https://stackoverflow.com/questions/3384134/alias-url-with-sinatra-padrino

Routing for controllers with multiple words in in Rails 4

这一生的挚爱 提交于 2019-12-05 04:52:52
I've just upgraded to Rails 4 and found an unexpected behaviour with routing. We have a controller named EmailPreviewController. The routing for this was: get "/emailpreview", controller: 'EmailPreview', action: :index however after upgrading to Rails 4 this throws the following error when the environment is loaded: 'EmailPreview' is not a supported controller name. This can lead to potential routing problems. See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use I've looked at the page it suggests however there isn't any indication that it's incorrect to use a

Routing to sub routing module without lazy loading

与世无争的帅哥 提交于 2019-12-05 04:34:27
I want to have multiple routing modules in order to keep my application clean and easy to read. I currently use lazy loading for the SubComponent but I don't want to do this. So I am looking for a way to change this. Anyways, here is the currently working code. I have the following two routing files. app-routing.module.ts : import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; const routes: Routes = [ { path: '', component: HomeComponent }, { path: 'sub', loadChildren: './sub/sub.module#SubModule' } ]; @NgModule({ imports: [RouterModule.forRoot