Search code examples
blazorblazor-server-sideblazor-client-sideblazor-webassemblyasp.net-blazor

Blazor - Is it safe to put SQL connection classes in Shared project


I wrote SQL connection classes for my Blazor app inside the Server project, but i can't access them from the Client Project.

Would it be safe to put all my SQL connection files containing connection strings in the Shared project ?

Thanks


Solution

  • If you put into a server side Blazor it could be ok. For Wasm definietly not.


    Normaly don't put any secrets into code in form of hard coded strings. Probably you are safer if you use appsettings.json with secret manager of VS in dev environment. For other env. I would use environmental variables or a secret manager/key vault.