url-routing

How to route legacy type urls in ASP.NET MVC

一曲冷凌霜 提交于 2019-12-08 08:08:20
问题 Due to factors outside my control, I need to handle urls like this: http://www.bob.com/dosomething.asp?val=42 I would like to route them to a specific controller/action with the val already parsed and bound (i.e. an argument to the action). Ideally my action would look like this: ActionResult BackwardCompatibleAction(int val) I found this question: ASP.Net MVC routing legacy URLs passing querystring Ids to controller actions but the redirects are not acceptable. I have tried routes that parse

php url routing question

淺唱寂寞╮ 提交于 2019-12-08 05:11:46
问题 http://mysite.com/songs/company-name/song-name i want to redirect it to http://mysite.com/songs/index.php?name=company-name&song=song-name i read some articles about that mod_rewrite but actually i couldnt understand exactyly, i appreciate if you can help me. thanks EDIT: mod rewrite is enabled 回答1: Check if your apache installation has mod_rewrite enabled. In its simplest form, the rule to accomplish what you want to do would be: In your .htaccess Options +FollowSymLinks RewriteEngine on

How to capture callback from failed validation in Joi

你。 提交于 2019-12-08 04:54:49
问题 We're building a web service using Hapi. Our routes have some validation. I was wondering if it was possible to capture or override the default callback on failed validation, before or after hapi replies to the client. my (non-working) code: { method: 'GET', config: { tags: tags, validate: { params: { id: Joi.number() .required() .description('id of object you want to get'), }, //Tried this, and it's not working: callback: function(err, value) { if (err) { console.log('need to catch errors

301 Redirect original URL request to routed URL

一个人想着一个人 提交于 2019-12-08 04:30:42
问题 I'm using the following code in my Global.asax file for url-rewriting: routes.MapRoute( "BlogArticle", "Blog/Article/{filename}", new { controller = "Blog", action = "Article" } ); This means the following URL: /Blog/Article/blog-article-title Will load the following Action: /Blog/Article?filename=blog-article-title I've noticed that the original URL path will still load my page. This could cause problems if the URL rewriting was added to the site months after the site went live. Google will

How do I ensure lower case URLs on POST?

柔情痞子 提交于 2019-12-08 04:26:14
问题 I am trying to ensure that all URLs used to access my ASP.NET MVC site are lower case. In the event that an upper case letter is in the URL, I'm changing the status code to 301 and changing the location to the lowercase version of the URL with this code: protected void Application_BeginRequest(object sender, EventArgs e) { var url = Request.Url.ToString(); if (Regex.IsMatch(url, @"[A-Z]")) { Response.Clear(); Response.Status = "301 Moved Permanently"; Response.StatusCode = (int)HttpStatusCode

Laravel full URL routing

☆樱花仙子☆ 提交于 2019-12-08 03:47:55
问题 How can I set my routes depending on the domain-name? I want to register some actions to diffenrent domain-names (not sub-domains). Example of the functionality I need to replicate: Route::any('www.domain1.com', 'Controler@Action1'); Route::any('www.domain2.com', 'Controler@Action2'); I can't use URL rewriting in .htaccess because I store domain->route maping in my database. 回答1: i think you can do it like this Route::group(array('domain'=>'www.domain1.com'), function(){ Route::get('/',array(

How to match numbers in an array in PHP

十年热恋 提交于 2019-12-08 03:41:55
问题 I am working on the routing or uri's in my PHP app. Currently I have an array with a regex => url map like this... <?php $uri_routes = array( //users/account like http://mysite.com/users/324 (any digit) 'users/friends/page-(\d+)' => 'modules/users/friends/page-$1', 'users/friends/' => 'modules/users/friends/', 'users/online' => 'modules/users/online/' , 'users/online/page-(\d+)' => 'modules/users/online/page-$1', 'users/create' => 'modules/users/create', 'users/settings' => 'modules/users

Match route relative to path

╄→гoц情女王★ 提交于 2019-12-08 03:30:49
问题 I want any URL that ends with /templates/{filename} to map to a specific controller using either a route attribute i.e. something like: public class TemplateController : Controller { [Route("templates/{templateFilename}")] public ActionResult Index(string templateFilename) { .... } } which works, but the links referencing this route are relative so http://localhost/templates/t1 -- works http://localhost/foo/bar/templates/t2 -- breaks (404) I need something like: [Route("*/templates/

Is it OK to send a 301 redirect with an action filter?

廉价感情. 提交于 2019-12-08 02:30:48
问题 I'm writing a new asp.net mvc application and I've been toying with the idea of allowing my user to post short, concise urls to content that he has posted. Those short url's will be handy in cramped spaces like Twitter and comment areas. I like this idea as I'm not a huge fan of url shorteners because they're so vague and you're never really sure what you're going to get. Instead of using a url shortener I want to give my client the ability to post: http://domain.com/p/234 which does a 301

MVC 3 Routing and Action Links not following expected contextual Route

我与影子孤独终老i 提交于 2019-12-08 02:05:53
问题 I'm attempting to do a custom route so I can prefix a url in my application with a chosen string and the do some processing based on that. The problem I'm running into is, that the action links that are generated are not contextualized based on the url that it exists on. Routes: routes.MapRoute( "TestRoute", "TEST/{controller}/{action}/{id}", new { controller = "Space", action = "Index", id = UrlParameter.Optional }); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller