routing

Call the default asp.net HttpHandler from a custom handler

半城伤御伤魂 提交于 2019-12-02 21:02:26
I'm adding ASP.NET routing to an older webforms app. I'm using a custom HttpHandler to process everything. In some situations I would like to map a particular path back to an aspx file, so I need to just pass control back to the default HttpHandler for asp.net. The closest I've gotten is this public void ProcessRequest(HttpContext context) { // .. when we decide to pass it on var handler = new System.Web.UI.Page(); handler.ProcessRequest(context); MemoryStream steam = new MemoryStream(); StreamWriter writer = new StreamWriter(stream); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);

ASP.NET MVC Routing Question

醉酒当歌 提交于 2019-12-02 20:54:56
I must be dense. After asking several questions on StackOverflow, I am still at a loss when it comes to grasping the new routing engine provided with ASP.NET MVC. I think I've narrowed down the problem to a very simple one, which, if solved, would probably allow me to solve the rest of my routing issues. So here it is: How would you register a route to support a Twitter-like URL for user profiles? www.twitter.com/username Assume the need to also support: the default {controller}/{action}/{id} route. URLs like: www.twitter.com/login www.twitter.com/register Is this possible? What about routes

How can I implement multiple URL parameters in a Tornado route?

柔情痞子 提交于 2019-12-02 20:46:10
I'm trying to figure out how to implement a URL with up to 3 (optional) url parameters. I figured out how to do this in ASP.NET MVC 3, but the constraints of the current project eliminated it. So, here's what I'm looking for: base/{param1}/{param2}/{param3} where param2 and param3 are optional. Is this simply a regex pattern in the handlers section? I'm not sure if there is a nice way to do it, but this should work: import tornado.web import tornado.httpserver class TestParamsHandler(tornado.web.RequestHandler): def get(self, param1, param2, param3): param2 = param2 if param2 else 'default2'

In Symfony2 how do I redirect within a Controller to a URL with an anchor tag/hash

匆匆过客 提交于 2019-12-02 20:38:24
I'm in a Controller and I want to redirect back to a URL, say /home/news/example#comment1423 How can I add the hash in to the return params? return $this->redirect( $this->generateUrl("news_view", array("permalink" => "example")) ); gilden The simplest solution would probably be concatenation: $url = $this->generateUrl("news_view", array("permalink" => "example")); return $this->redirect( sprintf('%s#%s', $url, 'comment1423') ); In Symfony 3.2 you can do this: // generating a URL with a fragment (/settings#password) $this->redirectToRoute('user_settings', ['_fragment' => 'password']); See

express js 4 how to serve json results without rendering any views /css

依然范特西╮ 提交于 2019-12-02 20:37:53
I am using express 4 in order to create a json API service. I can't seem to define it to send a simple json without trying to render the view. var express = require('express'); var router = express.Router(); module.exports = function (app, namespace) { router.get('/', function(req, res) { res.json({'body': 123}); }); app.use(namespace + '/v1', router); }; when I access the route it's Error: Failed to lookup view "error" in views directory "/Volumes/api_service/init/views" I tried to remove the views engine all together //app.set('views', path.join(__dirname, 'views')); //app.set('view engine',

Active Admin Ruby on rails Dashboard Controller Error

无人久伴 提交于 2019-12-02 20:35:13
All of a sudden my app seems to have developed a routing error uninitialized constant DashboardController I am running Rails 3.2.0 with ActiveAdmin (0.6.0) and up until today everything seemed to be working fine. The log is reporting the following error which occuring when trying to run localhost:3000: Started GET "/" for 127.0.0.1 at 2013-04-04 18:59:21 +0100 ActionController::RoutingError (uninitialized constant DashboardController): activesupport (3.2.0) lib/active_support/inflector/methods.rb:226:in `block in constantize' activesupport (3.2.0) lib/active_support/inflector/methods.rb:225:in

How to force https for prod but http for dev environment?

感情迁移 提交于 2019-12-02 20:27:49
I have a symfony2 application. On the prod server I want all my routes to go via https, while in dev I want to be able to use http. How do I achieve that with symfony2 alone? I do not want to touch the webserver configuration. I tried adding this in my routing.yml myBundle: resource: "@MyBundle/Controller/" type: annotation prefix: / schemes: [https] while having this in my routing_dev.yml : myBundle: resource: "@MyBundle/Controller/" type: annotation prefix: / schemes: [http] _main: resource: routing.yml It still wants to go to https even in dev mode. pazulx You can define parameter for that.

Angular 2 Activatedroute params not working in Service or outside <router-outlet>

拥有回忆 提交于 2019-12-02 20:20:16
I have a very strange problem: index.html <navigation-menu *ngIf="isLoggedIn"></navigation-menu> <div class="content-wrapper" [ngClass]="{'fullContent' : !isLoggedIn}"> <section class="content"> <router-outlet></router-outlet> </section> </div> The navigation-menu is a component for the nav menu. In router-outlet content there is a component called "assets". What I did in asset component: import { ActivatedRoute}from "@angular/router"; constructor(private route: ActivatedRoute){} public ngOnInit(): void { this.route.params.subscribe(params => { const id = params["id"]; } This works and I get

on html.actionlink click go to previous page

孤者浪人 提交于 2019-12-02 20:06:56
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? something like @Html.ActionLink("Back to Details", //go to previous page) Unless you're tracking what

How to generate Absolute URL from Early/Auto loaded Symfony 3 router

≡放荡痞女 提交于 2019-12-02 19:37:07
问题 I am writing Guards to handle OAuth for my Symfony 3 application. As part of it, in one of my services, I need to generate an absolute URL to send to Twitter as the Callback URL. #services.yml ... app.twitter_client: class: MyApiBundle\Services\TwitterClient arguments: - %twitter_client_id% - %twitter_client_secret% - connect_twitter_check - '@request_stack' - '@router' - '@logger' app.twitter_authenticator: class: MyApiBundle\Security\TwitterAuthenticator arguments: - '@app.twitter_client' -