Base solution for your next web application
Open Closed

Angular 2 routing problem #2523


User avatar
0
walkerscott created

I have followed this documentation to setup angular2+Core Solution <a class="postlink" href="https://www.aspnetzero.com/Documents/Getting-Started-Angular">https://www.aspnetzero.com/Documents/Ge ... ed-Angular</a>

things went really good as expected. But after successful login I'm unable to see dashboard, it redirects me back to login. I can find response of getCurrentLoginInformations in network tab of chrome developer area as below:

{"result":{"user":{"name":"admin","surname":"admin","userName":"admin","emailAddress":"[email protected]","profilePictureId":null,"id":1},"tenant":null,"application":{"version":"3.1.0.0","releaseDate":"2017-02-21T11:49:24.2387011+05:00"}},"targetUrl":null,"success":true,"error":null,"unAuthorizedRequest":false,"__abp":true}

but still getting navigated to login page. I guess in auth-route-guard.ts inside canActivate method its finding this._sessionService Undefined so navigating to login again?


11 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you try two things,

    1 - remove cookies in chrome and try to login again ? 2 - If it does not work, can you try to write some logs in main.ts and AppPreBootstrap.ts and see which line it reaches when you login.

    If this._sessionService is undefined, there must be an error log on chrome's console, but I think it is not there right ?

    Thanks.

  • User Avatar
    0
    walkerscott created

    have a look at the following image here we can see each call is made twice and in every first call there is no response. <a class="postlink" href="https://www.dropbox.com/s/16q553pjjh09hgs/login%20issue.png?dl=0">https://www.dropbox.com/s/16q553pjjh09h ... e.png?dl=0</a>

  • User Avatar
    0
    walkerscott created

    I have tried both solution none worked for me.

  • User Avatar
    0
    walkerscott created

    Hey is there a way to get it working fine? its telling different story in microsoft edge <a class="postlink" href="https://www.dropbox.com/s/792irlyxnmoj7xt/login11111111111.png?dl=0">https://www.dropbox.com/s/792irlyxnmoj7 ... 1.png?dl=0</a> How to get it working?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Two request is not a problem, it is the way angular works. Can you send your generated project to us (<a href="mailto:[email protected]">[email protected]</a>) ? Please remove node_modules before sending.

    We will try to find the fix as soon as possible.

  • User Avatar
    0
    walkerscott created

    Ok I'm sending now.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thank, waiting for it.

  • User Avatar
    0
    walkerscott created

    Hey I've sent email please come back at your earliest. thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I have downloaded the project and followed below steps. It worked for me.

    • removed this line from angular-cli.json
    "environmentSource": "environments/environment.ts",
    
    • installed node_modules using "yarn install" command. You can remove node_modules folder and reinstall it again.

    After these steps, I successfully logged in to application. You can also try to clean cookies in your browser.

    Thanks.

  • User Avatar
    0
    walkerscott created

    Thanks, it worked this way, but why we are unable to use npm straight away? However in documentation its mentioned that either use yarn or npm install. When run npm install it throws an error which can be fixed by adding that specific line you asked to remove. So this is an open issue I guess.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    That is good, at least problem is solved :).

    Can you share error message or a screenshot for npm ? You can use npm but it is better to use yarn because it guarantees the installed package versions will be same with developed versions. By default npm can install newer versions of packages and it might cause some problems. As far as I know npm has a similar approach but we didn't apply it into our project.

    By the way, can you write versions of below tools in your computer ?

    • node
    • npm
    • angular-cli

    Thanks.