routing

ASP.NET MVC: url routing vs querystring

房东的猫 提交于 2019-12-17 17:36:13
问题 I have a page routed like /Comments/Search/3 where i search and display all the comments of the thread "3". I'm adding a sort function (by date, author etc). What is the best way to handle it? /Comments/Search/3/Sort/Author or /Comments/Search/3?sort=author ? How do I automatically handle the querystring sort=author as a parameter in MVC? Thanks 回答1: I prefer: /Comments/Search/3?sort=author. The querystring is a good place to pass in programmatic parameters, especially if the parameter (like

Routing nested resources in Rails 3

我与影子孤独终老i 提交于 2019-12-17 17:34:07
问题 I have a pretty common case for nested routes, I feel like, that looks something like this (in some sort of pseudonotation): '/:username/photos' => Show photos for User.find_by_username '/photos' => Show photos for User.all In a nutshell: I have users. They have photos. I want to be able to show their photos on their page. I also want to be able to show all photos, regardless of the user. I'd like to keep my routes RESTful and using the built-in resource methods feels like the right way to do

Register multiple routes using range for loop slices/map

∥☆過路亽.° 提交于 2019-12-17 17:11:49
问题 Consider I have slice of string paths: paths := []string{"/path0", "/path1", "/path2" /*... "/path-n"*/ } // where n is the last path Using package net/http , I want to register handler for this path using for loop with range clause. This is how I do this: for _, path := range paths { http.HandleFunc(path, handler) } // in this case every handler is print the path to the console or to the browser EDIT: Basically the asker used this code: for _, path := range paths { http.HandleFunc(path, func

Domain name for my PC: how to (tried No-IP, DuckDNS and ngrok)

梦想的初衷 提交于 2019-12-17 16:54:31
问题 I want: ping server on my PC by it domain name from remote. I have: DynDNS services DuckDns (or No-IP, config in no-ip is even harder). It gets me an IP 94.154.220.216 and (sub)domain http://my_domain.duckdns.org . To configure DuckDNS on PC I need just specify some token and my domain name ( my_domain ). Also I've launched server on lacalhost:3000 . Also when I go to CanYouSeeMee it says that my IP is 94.154.220.216 (that's good). And I configured static IP for my PC (let's say 200.300.1.15

ASP.NET Application hosted on IIS7 that is ignoring custom errors and falls back to IIS errors

给你一囗甜甜゛ 提交于 2019-12-17 16:33:11
问题 I have a C# web forms ASP.NET 4.0 web application that uses Routing for URLs for some reason custom errors defined in the system.web section of my web.config is entirely ignored and it will fall back the IIS errors. This gets entirely ignored <system.web> <customErrors mode="On"> <error statusCode="500" redirect="~/Error" /> <error statusCode="404" redirect="~/404" /> <error statusCode="403" redirect="~/Error" /> </customErrors> </system.web> This part takes over <system.webServer>

Adding a prefix to every URL in CakePHP

故事扮演 提交于 2019-12-17 15:39:08
问题 What's the cleanest way to add a prefix to every URL in CakePHP, like a language parameter? http://example.com/en/controller/action http://example.com/ru/admin/controller/action It needs to work with "real" prefixes like admin , and ideally the bare URL /controller/action could be redirected to /DEFAULT-LANGUAGE/controller/action . It's working in a retro-fitted application for me now, but it was kind of a hack, and I need to include the language parameter by hand in most links, which is not

MVC 3 Subdomain Routing [duplicate]

一笑奈何 提交于 2019-12-17 15:17:24
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Is it possible to make an ASP.NET MVC route based on a subdomain? In asp.net MVC 3 site i'd like to create online stores for users. Any store that is created by user should have a URL like " shopname .mydomain.com" . I tried some routing work but failed at all. I am researching for a solution but cannot find any proper solution. My purpose is that; if I can add a route to manage any request that tries to find a

asp.net 4.0 web forms routing - default/wildcard route

二次信任 提交于 2019-12-17 11:01:51
问题 I there a simple way when using ASP.NET 4.0 routing with Web Forms to produce a route that will act as some kind of wildcard? It seems to me that within WebForms, you have to specify a route for every page - I am looking for some kind of generic route that can be used where nothing specific is required, perhaps mapping directly from path to path so... http://somedomain.com/folder1/folder2/page would possibly map to folder1/folder2/page.aspx Any suggestions? Thanks 回答1: You can match all

asp.net 4.0 web forms routing - default/wildcard route

不问归期 提交于 2019-12-17 11:01:48
问题 I there a simple way when using ASP.NET 4.0 routing with Web Forms to produce a route that will act as some kind of wildcard? It seems to me that within WebForms, you have to specify a route for every page - I am looking for some kind of generic route that can be used where nothing specific is required, perhaps mapping directly from path to path so... http://somedomain.com/folder1/folder2/page would possibly map to folder1/folder2/page.aspx Any suggestions? Thanks 回答1: You can match all

Multiple canActivate guards all run when first fails

你。 提交于 2019-12-17 10:32:41
问题 I have a route with two canActivate guards ( AuthGuard and RoleGuard ). The first ( AuthGuard ) checks to see if the user is logged in and, if not, redirects to the login page. The second checks to see if the user has a role defined that is allowed to view the page and, if not, redirects to the un-authorized page. canActivate: [ AuthGuard, RoleGuard ] ... export class AuthGuard implements CanActivate { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {