1

I'm trying to pass an e-mail address as a query string parameter to an Aurelia route.

The URL looks like: http://localhost/some/route?email=john@doe.com

However, it seems the dot (period) in the URL breaks the Aurelia route, resulting in a 404.

If I remove the dot, the route loads just fine.

Any ideas what's causing this? I'm surprised I can't find any information on it, having periods in a route should be fairly common?

Thanks!

Edit: Seems this may not be an Aurelia issue, but rather an ASP.NET MVC issue: Dots in URL causes 404 with ASP.NET mvc and IIS

Community
  • 1
  • 1
Ted Nyberg
  • 7,001
  • 7
  • 41
  • 72

1 Answers1

1

It seems to work fine with the basic setup like below. I've whipped this up together with the latest Aurelia CLI (v0.23). In this setup there are three files: the view (html), the viewmodel (ts) and the route (app.ts):

views/edit-dots.html

<template>
    <p>email: ${email}</p>
</template>

views/edit-dots.ts

export class EditDots {
    public email;

    activate(params: any) {
        console.log('here are *all* your parameters: ', params);
        this.email = params.email;
    }
}

And finally, the route config (in app.ts in my case):

import { Router, RouterConfiguration } from 'aurelia-router'

export class App {

    router: Router;

    configureRouter(config: RouterConfiguration, router: Router) {
    config.title = 'Stack';
    config.map([
        { route: ['', 'home'], name: 'home', moduleId: './views/home', nav: true, title: 'Home' },
        { route: 'dots/:id', name: 'edit-dots', moduleId: './views/edit-dots', nav: false, title: 'Create a dot' }
    ]);

    this.router = router;
    }
}

When I navigate to http://localhost:9001/#dots/42?email=harry@potter.com with this setup, it neatly displays the email address. Of course, I can remove the '42', it is just for demonstration purposes.

Final note, your example url doesn't seem to use the #-sign. If this is intentional, you might want to give some more details about your configuration. Otherwise, does it help adding it?

Perhaps this helps you as well?

Juliën
  • 9,047
  • 7
  • 49
  • 80
  • The app is configured for push state, so there's no hashbang in the URL. Perhaps there's an issue when push state is enabled...? – Ted Nyberg Dec 27 '16 at 12:24
  • 1
    Indeed, if you're using for example ASP.NET (MVC) for your Push State this is [a known issue](http://stackoverflow.com/questions/11728846/dots-in-url-causes-404-with-asp-net-mvc-and-iis). Other technologies, or toolings, might have issues as well? – Juliën Dec 27 '16 at 12:28
  • Wow, that's eerily similar to my problem. :) Can't believe I stared myself blind at Aurelia - rookie mistake! Thanks for your help! – Ted Nyberg Dec 27 '16 at 12:57