Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Can't pass "hi" into DynamicDictionary #1446

Closed
scott-xu opened this issue Feb 6, 2014 · 9 comments · Fixed by #1447
Closed

Can't pass "hi" into DynamicDictionary #1446

scott-xu opened this issue Feb 6, 2014 · 9 comments · Fixed by #1447

Comments

@scott-xu
Copy link

scott-xu commented Feb 6, 2014

This is really a very strange thing:

this.Get["/{name?}"] = _ => this.View["Index", _.name];

When I navigate to http://localhost/abc or http://localhost/blablabla, I can get the name property as expected. But when I navigate to http://localhost/hi, I can't get it. The dynamic dictionary is empty (count equals 0)

@jchannon
Copy link
Member

jchannon commented Feb 6, 2014

Maybe this is an issue with your view. Using Get["/{name?}"] = _ => _.name; works fine

@scott-xu
Copy link
Author

scott-xu commented Feb 7, 2014

Still no luck.
It's easy to reproduce:

  1. Create an empty web application
  2. Install packages: Nancy.Owin, OwinHost
  3. Create Startup.cs
public class Startup
{
    public void Configuration(IAppBuilder builder)
    {
        builder.UseNancy();
    }
}

Create MainModule.cs

public MainModule()
{
    this.Get["/{name?}"] = _ => _.name;
}

Make sure use OwinHost as server.
Press F5 and run
http://localhost:12345/abc - works as expected
http://localhost:12345/hi - doesn't work

@jchannon
Copy link
Member

jchannon commented Feb 7, 2014

@scott-xu
Copy link
Author

scott-xu commented Feb 7, 2014

Yes, I do read this.
I'm just using OwinHost.exe as the server. It works for any other words but not "hi"

@damianh
Copy link
Member

damianh commented Feb 7, 2014

@scott-xu can you put together a repro project on github that we can download and run? Thx.

@damianh
Copy link
Member

damianh commented Feb 7, 2014

@scott-xu "on github" thx.

@scott-xu
Copy link
Author

scott-xu commented Feb 7, 2014

@damianh
Copy link
Member

damianh commented Feb 7, 2014

Thanks @scott-xu , looking at it now.

@grumpydev
Copy link
Member

Ok, we've gotten to the bottom of it, it's down to localisation.

One of the default conventions NAncy uses to determine the current request locale is look at the start of the path, if it matches a locale string then it strips it, sets the locale and continues. Unfortunately, as a side effect of supporting partial locals (so en rather then en-GB) that means we're stripping quite a lot of innocent two letter parameters.

I think the best solution to this is to disable that convention by default - it's simple enough to put back in.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants