ASP.NET URL Rewriting

Try the Managed Fusion Url Rewriter and Reverse Proxy: http://urlrewriter.codeplex.com The rule for rewriting this would be: # clean up old rules and forward to new URL RewriteRule ^/?user=(.*) /users/$1 [NC,R=301] # rewrite the rule internally RewriteRule ^/users/(.*) /?user=$1 [NC,L]

Flask url_for generating http URL instead of https

With Flask 0.10, there will be a much better solution available than wrapping url_for. If you look at https://github.com/mitsuhiko/flask/commit/b5069d07a24a3c3a54fb056aa6f4076a0e7088c7, a _scheme parameter has been added. Which means you can do the following: url_for(‘secure_thingy’, _external=True, _scheme=”https”, viewarg1=1, …) _scheme sets the URL scheme, generating a URL like https://.. instead of http://. However, by default Flask only … Read more

PHP Application URL Routing

I prefer to use reg ex over making my own format since it is common knowledge. I wrote a small class that I use which allows me to nest these reg ex routing tables. I use to use something similar that was implemented by inheritance but it didn’t need inheritance so I rewrote it. I … Read more

Appending form input value to action url as path

You can use onsubmit attribute and set the action inside a function for example: <form id=”your_form” onsubmit=”yourFunction()”> <input type=”text” name=”keywords”> <input type=”submit” value=”Search”> </form> function yourFunction(){ var action_src = “http://localhost/test/” + document.getElementsByName(“keywords”)[0].value; var your_form = document.getElementById(‘your_form’); your_form.action = action_src ; }

How to get RouteData by URL?

I used Moq to determine what members of HttpContextBase are used in GetRouteData(). They are: Request AppRelativeCurrentExecutionFilePath PathInfo Request.AppRelativeCurrentExecutionFilePath should return path with ~, what I exactly need, so utility class may be like this one: public static class RouteUtils { public static RouteData GetRouteDataByUrl(string url) { return RouteTable.Routes.GetRouteData(new RewritedHttpContextBase(url)); } private class RewritedHttpContextBase : … Read more

Client Routing (using react-router) and Server-Side Routing

Note, this answer covers React Router version 0.13.x – the upcoming version 1.0 looks like it will have significantly different implementation details Server This is a minimal server.js with react-router: var express = require(‘express’) var React = require(‘react’) var Router = require(‘react-router’) var routes = require(‘./routes’) var app = express() // …express config… app.use(function(req, res, … Read more

ASP.NET MVC Url Route supporting (dot)

Add a UrlRoutingHandler to the web.config. This requires your url to be a bit more specific however (f.e. /Users/john.lee). This forces every url starting with /Users to be treated as a MVC url: <system.webServer> <handlers> <add name=”UrlRoutingHandler” type=”System.Web.Routing.UrlRoutingHandler, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” path=”/Users/*” verb=”GET”/> </handlers> </system.webServer>