我正在尝试将电子邮件地址作为查询字符串参数传递给Aurelia路由.
I'm trying to pass an e-mail address as a query string parameter to an Aurelia route.
URL看起来像: localhost/some/route?email=john@doe
但是,URL中的点(句点)似乎中断了Aurelia路由,导致了 404 .
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?
谢谢!
似乎这可能不是Aurelia问题,而是ASP.NET MVC问题: URL中的点导致使用ASP.NET mvc和IIS的404
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
推荐答案在以下基本设置中似乎可以正常使用.我将其与最新的Aurelia CLI(v0.23)结合在一起.在此设置中,有三个文件:视图(html),视图模型(ts)和路线(app.ts):
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>视图/edit-dots.ts
export class EditDots { public email; activate(params: any) { console.log('here are *all* your parameters: ', params); this.email = params.email; } }最后,路由配置(在我的情况下为 app.ts ):
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; } }当我导航到 localhost:9001/#dots/42?email=harry@potter 使用此设置,它可以整齐地显示电子邮件地址.当然,我可以删除"42",仅用于演示目的.
When I navigate to localhost:9001/#dots/42?email=harry@potter 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?
也许这对您也有帮助?
更多推荐
查询字符串参数中的句点中断Aurelia路由
发布评论