Asked by:
Can we print blazor variables from browser console

Question
-
User-1619000197 posted
e.g if we have a variable "x" in JS we can print it from console using console.log(x). right?
now as blazor code run in the same sandbox security as javascript so e.g if we have a variable x in our c# code is there any way that a user (if know the variable name) able to print the variable value Using JSInterop or something??
Monday, September 21, 2020 11:56 AM
All replies
-
User475983607 posted
It's just the standard Console output.
Console.Write(); Console.WriteLine();
Monday, September 21, 2020 12:25 PM -
User-1619000197 posted
That's i know what i am trying to ask is can i print variable in our blazor app inside the browser using browser console
Tuesday, September 22, 2020 7:09 AM -
User475983607 posted
That's i know what i am trying to ask is can i print variable in our blazor app inside the browser using browser console
If I understand the question, No.
However, Console.WriteLine() writes to the dev tools console. Use the standard debugger if you want to set a variable during runtime.
Tuesday, September 22, 2020 1:57 PM -
User-1619000197 posted
Okay i get. and no i don't want to set a variable during runtime i am just keeping an List<string> temporary so when user input any thing in a field i check if it exist in that List<string> or not.
so i want to make sure that user can't access that array through console and modify it.
Thursday, September 24, 2020 7:45 AM -
User475983607 posted
You could have made a simple test and tried this yourself.
Thursday, September 24, 2020 11:37 AM -
User-1619000197 posted
You could have made a simple test and tried this yourself.
i have tried and it's not working and as i mention in my question( Using JSInterop or something??) so i want to be aware of other other possibilities which now i think is none. anyway Thanks for answering
Friday, September 25, 2020 4:09 AM