Simo
❔ DIY logging methods
I'm working on an old old codebase and I've noticed it has effectively implemented its own logging class, to append timestamps and so on.
The code has
all through it, and if debugging is turned off, the Log method just does nothing with the string. - this does get called maybe 800,000 times in a day, but mostly with the logging turned off.
Am I right in saying that the calling code will allocate all the strings every time, even when the debug is turned off internally? i.e. it would be more efficient to not call debug in the first place, so we dont allocate that string 800,000 times day?
27 replies
❔ What is happening under the covers to allow this to work
someRandomString.Split('.').Select(HttpUtility.HtmlDecode);
From the definition of HtmlDecode, it has an anonymous constructor, and one which takes a 's' parameter for the string. How on earth is this linq working that it can somehow construct it and pass the string in and get the result?11 replies
❔ Handling invalid uploads
If I make a controller, which accepts a file upload POST, which only accepts pdf.
if someone uploads a .docx for example, and I throw the error, does this error get thrown only after the entire file is uploaded anyway? i.e. its a bit silly because they wasted their time uploading the file only to receive an error?
4 replies
❔ ef migration snapshots
If I use the same project to deploy to dev and then live, do I need to clear the model snapshots? it seems it may hold dev-relevant information in there and mess up the live migration (I've noticed some of our migrations appear to not be included on live now)
12 replies
passing license keys to a unit test
I would like to use a 3rd party DLL which needs a license key passed in, however I cannot find a way to do this, as the unit test project seems to ignore
launchSettings.json
, and I don't want to hard-code the key anywhere in the test itself.
on Live this comes from an environment variable12 replies
require `mfa` claim only when user has `TwoFactorEnabled`
Hi,
I have setup multifactor in my dotnet core MVC API, I have it saving the tokens and validating on your mfa code on login. when you login and enter your code, I set a
mfa
claim, which I then check in an AuthorizationHandler
.
The thought was that with this AuthorizationHandler
it will stop someone bypassing the mfa code-entry part of the 2-step login.
However in my AuthorizationHandler
I only want to validate the token if the mfa
claim is there when the user has TwoFactorEnabled
set on their user. I can't find an easy way to access the user information.
A user without TwoFactorEnabled
should still be able to access things
Can anyone think of a solution to this?2 replies