Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

Using Angular 1.5 in an asp.net mvc site.

I have a base tag:

<base href="/fr/">

and html5mode is set.

The site works perfectly. I use ui-router... no issues. But today I hit one and this is when I try to browse to this kind of url:

http://example.com/fr?arg=1

I get an error from angular:

url is undefined

If I navigate to /fr/?arg=1 (with the trailing slash) the error goes away.
If I navigate to /fr/about/?arg=1, it will navigate to the index page but won't trigger the "about" state.

How to get the query string to work?

Update: setting strictMode to false, as @miqid proposed, fixed the issue for this url /fr/about/?arg=1 but not for the base /fr?arg=1

share|improve this question
    
UrlMatcher takes an argument named strict that lets you customise the behaviour of URL matching when trailing slashes are involved. You can use this as the url property of a state to not require trailing slashes with query strings. – miqid Feb 11 at 0:09
    
@miqid Thank you. Unfortunately, my dev machine is in distress today and I will have to reinstall a lot of things. I will come back to you as soon as I can test what you proposed. – Nicolas Cadilhac Feb 11 at 14:53
    
@miqid ok, was able to test. I tried calling $urlMatcherFactoryProvider.strictMode(false); before defining the states and it changed nothing. Did you mean something else? How should I configure a UrlMatcher? Please, write an answer as a full post. – Nicolas Cadilhac Feb 11 at 18:28
    
Without seeing more context of your setup, there's not much else I can suggest, because the problem might actually be something else. However, here's a basic Plunker I wrote which illustrates the effect of strictMode and catching routes with or without trailing slashes. Do take a look - plnkr.co/edit/n9mRfw?p=preview – miqid Feb 12 at 3:22
    
Thanks. I tried your plunker. It demonstrates the contrary of my issue. I have no problems with trailing slashes. If have a problem when I remove it. Note also, that my issue is only on the base url (I don't know why it was not working when I created this post but today it works). So only example.com/fr?arg=1 is not working. Your plunker does not show this and I can't succeed making it work with a state '/'. At last, note that the problem happens only when typing an url in the address bar. Creating an href="?arg=1" works and creates a url with the trailing slash anyway. – Nicolas Cadilhac Feb 12 at 13:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.