Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Error on load #1

Closed
sherbertiConstruct opened this issue Sep 22, 2017 · 12 comments
Closed

Error on load #1

sherbertiConstruct opened this issue Sep 22, 2017 · 12 comments

Comments

@sherbertiConstruct
Copy link

After I have successfully logged in I get this error.

System.Exception: 'Cannot call /api/forge/session/isvalid'

@augustogoncalves
Copy link
Collaborator

do you have the localhost server running? Note you need to launch both.

@AugustinoJ
Copy link

I'm getting the same error (Cannot call /api/forge/session/isvalid). I have tried setting my solution to start both projects and I have right clicked on "cloud" and started an instance, then right clicked on "desktop" and started an instance. Same error each time. I've changed the host to be non secure (http) and that still doesn't work. How do you start the localhost server?

Snipped from my web.config:





Thanks,
Joe

@AugustinoJ
Copy link

It appears that this line:

        sessionId = Encoding.UTF8.GetString(System.Web.Security.MachineKey.Unprotect(Convert.FromBase64String(sessionId)));

in HeaderUtils.cs is causing the error. sessionId is a string before it runs through here but is an empty string when this line executes. I've tried commenting out this line but then I get a different RESTAPI response error.

Can you please help with this?
Thanks,
Joe

@augustogoncalves
Copy link
Collaborator

Just tried the sample, works fine, I would suggest you clean the MongoDB database, maybe some data is corrupted and causing this. The sessionId enters this method as NULL, then is set to EMPTY, then the correct value from the cookie header.

I have upgraded the package versions, there is a change on how CefSharp handles cookies, see this line.

@OMH2Share
Copy link

OMH2Share commented Oct 30, 2018

I have the same problem. The login to Autocad is fine, then it fails on session/isvalid.
I have noted that in HeaderUtils.cs, the GetSessionLocalIDs method, the sessionId is NULL, EMPTY and correct value from cookie, however the unencrypt call always sets sessionId back to empty string.
Skipping the unencryption still gives the same error

EDIT: I resolved my problem above, it was due to a hardcoded database name in cloud\App_Code\Database.cs.
It must match the database name in your MongoDB!
I guess you can read it as the last part of the connection string.
Now it works perfectly, thanks!

@OMH2Share
Copy link

This change will read the database name from the connection string:

        private static IMongoDatabase Database
        {
            get
            {
                //Read database as last item on the connection string
                string[] parts = ConfigVariables.OAUTH_DATABASE.Split('/');
                string db = parts.Last();
                if (_database == null) _database = Client.GetDatabase(db);
                return _database;
            }
        }

@augustogoncalves
Copy link
Collaborator

thanks for the suggestion, @OMH2Share, will add that on the code (it's better 😄 )

@augustogoncalves
Copy link
Collaborator

fixed

@talebi talebi mentioned this issue Feb 26, 2019
Closed
@WspDev
Copy link

WspDev commented Aug 13, 2019

This seems to be the error I came up against.
It was caused by two things:

  1. Dirty database entries added by debugging process.
  2. The MongoDB filter being created, but not actually used.

(The returned database entry was just the first entry found, with an expired DateTime. Getting a refresh token failed as it was for an access token that had long expired. This caused a status 500 return value.)

The fix is to change
var docs = await users.FindAsync(new BsonDocument());
to
var docs = await users.Find(filter).ToListAsync();

@augustogoncalves
Copy link
Collaborator

thanks @WspDev, makes sense

@WspDev
Copy link

WspDev commented Aug 14, 2019

Thank you @augustogoncalves .
Did you intend to await await on the fix?

@augustogoncalves
Copy link
Collaborator

such a silly mistake here... thanks!
(push the wrong file)

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

No branches or pull requests

5 participants