c# - Basic Auth in .NET with Filter & Async MongoDB comparison Task.wait() never ends -


i have rest api basic filter. filter checks against db (mongodb) before actual request made, wether user authorized. works first time, afterwards gets stuck at

var filter = builders<user>.filter.eq("email", email); return  _collection.find(filter).firstordefaultasync(); 

which looks user in db based on email. task doesn't finish , neither throw timeout exception .

my question related : c# mongo firstordefaultasync hangs

however fix didn't me. can't keep passing async tasks call hierarchy because @ point filter expects sychronous action based on results. , await doesnt cut either.

any ideas? can't 1st 1 building rest api basic auth , mongodb behind it...

help appreciated:)


update:

a call results in problems:

//... await fbuserrepo.updateasync(user);  //the method public async task<guid> updateasync(tentity entity) {         entity.lastupdatedtimestamp = datetime.now;         var filter = builders<tentity>.filter.eq("_id", entity.id);         await _collection.replaceoneasync(filter, entity);         return entity.id;     } 

when method called, nothing happens, nothing returned.. stuck later @ .wait() ... haven't changed on configuration , happens both locally in azure cloud. performing queries directly on mongodb no problem, there no currentop() pending. no timeout thrown. application decided not anymore. thread stays still


update again

the odd part is: can crud sorts of stuff db. when come authenticationfilter trouble. crawled on 100k documents fb , dropped db, updated them, etc. fetching , updating user documents through basicauthfilter giving me trouble. can't explain it... might notice frustration (2am now..)

.result after sync method solve problem.

like given below.

var filter = builders<user>.filter.eq("email", email); return  _collection.find(filter).firstordefaultasync().result; 

however make sure, method you're working on isn't marked "async" async method should not blocking. more details here.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -