routing

ASP.NET MVC User routing like that in StackOverflow?

…衆ロ難τιáo~ 提交于 2019-11-30 12:33:22
I've looked at the routing on StackOverflow and I've got a very noobie question, but something I'd like clarification none the less. I'm looking specifically at the Users controller https://stackoverflow.com/Users https://stackoverflow.com/Users/Login https://stackoverflow.com/Users/124069/rockinthesixstring What I'm noticing is that there is a "Users" controller probably with a default "Index" action, and a "Login" action. The problem I am facing is that the login action can be ignored and a "UrlParameter.Optional [ID]" can also be used. How exactly does this look in the RegisterRoutes

Passing data through Angular2 router

浪子不回头ぞ 提交于 2019-11-30 11:59:06
问题 I have a component where I select a set of image objects. I want to pass these selected images to my new route, CreateAlbum. The data it nested and wouldn't be suitable to pass as URL parameters. Is there any easy way to achieve this? Here's my code to navigate to the route public gotoCreateAlbum(): void { this.router.navigate([('/create-album')]) } My selected data sits in this variable @Input() selectedPhotos: IPhoto[]; and this is my routing module const routes: Routes = [ { path: 'photos'

How to write controller tests when you override devise registration controller?

左心房为你撑大大i 提交于 2019-11-30 11:49:52
问题 I wish to override the Devise::RegistrationsController to implement some custom functionalality. To do this, I've created a new RegistrationsController like so: # /app/controllers/registrations_controller.rb class RegistrationsController < Devise::RegistrationsController def new super end end and set up my routes like this: devise_for :users, :controllers => { :registrations => "registrations" } and tried to test it like this: describe RegistrationsController do describe "GET 'new'" do it

angular 5 routing to same component but different param, not working

狂风中的少年 提交于 2019-11-30 11:42:29
I have angular 5 basic beginner level app there are just 5 components my routing and links look like this //copied from app.module.ts const appRoutes:Routes = [ {path:'',component:HomeComponent}, {path:'items/:cat',component:ItemsComponent}, {path:'itemdetail/:id',component:ItemdetailComponent}, {path:'settings',component:SettingsComponent}, ]; //copied from navbar.component.html <ul> <li><a [routerLink]="['/']">Home</a></li> <li><a [routerLink]="['/items/8']">Rashion</a></li> <li><a [routerLink]="['/items/2']">Vegitables</a></li> <li><a [routerLink]="['/items/3']">Fruits</a></li> <li><a

Redirecting from port 80 to different ports based on URL

与世无争的帅哥 提交于 2019-11-30 11:37:36
问题 I have two applications, (Atlassian JIRA and Confluence,) listening on ports 8080 and 8090, accessible through example.com:8080/jira and example.com:8090/confluence. I would like to set up a redirection on port 80 such that I can access the services through example.com/jira and example.com/confluence. Is there a simple way to achieve this? 回答1: There are 2 ways of solving this. Redirect Method You seem pretty savvy setting up servers. You will need a web Server running on port 80. (Apache:

Override route helper methods

一世执手 提交于 2019-11-30 11:37:07
Question has many Comments. A URL "questions/123" shows a question. A URL: "questions/123#answer-345" shows a question and highlights an answer. 345 - is id of Answer model, "answer-345" is id attribute of HTML element. I need to override "answer_path(a)" method to get "questions/123#answer-345" instead of "answers/345" How to do it ? All url and path helper methods accept optional arguments. What you're looking for is the anchor argument: question_path(123, :anchor => "answer-345") It's documented in the URLHelper#link_to examples . Using this argument, you should be able to create an answer

Routing to the actions with same names but different parameters

冷暖自知 提交于 2019-11-30 11:02:15
I have this set of routes: routes.MapRoute( "IssueType", "issue/{type}", new { controller = "Issue", action = "Index" } ); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); Here is the controller class: public class IssueController : Controller { public ActionResult Index() { // todo: redirect to concrete type return View(); } public ActionResult Index(string type) { return View(); } } why, when i request http://host/issue i get The current request for

Mass 301 redirects in ASP.NET, including pages that need to redirect to a different place depending on the query string parameters

人盡茶涼 提交于 2019-11-30 10:51:37
We have several pages of our site indexed using old non-SEO friendly URLS such as http://www.domain.com/DocumentDetails.aspx?id=555 . Recently we implemented routing that uses slugs stored in the database and looks up the slug to forward you to the right page using routing, for example: http://www.domain.com/Documents/Title-of-the-Document This is all well and good however we are having a hard time finding the best way to set up our 301 permanent redirects for all the links currently indexed by Google. Is there a way to have 1 centralized place to store old URL and new URL, and have it do the

Passing info to another action using RedirectToAction - MVC

六眼飞鱼酱① 提交于 2019-11-30 09:43:17
问题 I have this action: public ActionResult Report(AdminReportRequest reportRequest, FormCollection formVariables) { AdminEngine re = new AdminEngine(); AdminReport report = re.GetCompleteAdminReport(reportRequest); return View(report); } I was wondering how could I go about Redirecting to another action within the same controller, passing the AdminReportRequest, and FormCollection variables? I had something like this in mind: public ActionResult EarningsSalesReport(AdminReportRequest

laravel routing and 404 error

南笙酒味 提交于 2019-11-30 09:28:40
I want to specify that if anything entered in the url address other than existing routes (in routes.php, then show 404 page. I know about this: App::abort(404); but how can I specify the part where everything else except the routes defined? You can add this to your filters.php file: App::missing(function($exception) { return Response::view('errors.missing', array(), 404); }); And create the errors.missing view file to show them the error. Also take a look at the Errors & Logging docs EDIT If you need to pass data to that view, the second parameter is an array you can use: App::missing(function