0
I’m new to ASP.NET with C# and have a problem accessing the information on my web.config.
This is the connection tag to the database:
<connectionStrings>
<add name="someConnection" connectionString="SomeInformation" providerName="System.Data.SqlClient" />
</connectionStrings>`
This is the function I’m using to try to retrieve the information:
string constr = ConfigurationManager.ConnectionStrings["someConnection"].ConnectionString;
This returns me the error "Using the generic Configutationmanager type requires 1 type argument", but I have tried typing the configurationManager and always returns the error "Configurationmanager does not contain a definition for Connectionstrings", regardless of the "T" that I put.
I need help, thank you.
Hello, Asp.net-core and
web.config
? you shouldn’t be putting your settings onappsettings.json
? Have a look at the documentation and tutorial https://docs.microsoft.com/pt-br/aspnet/core/tutorials/razor-pages/sql?view=aspnetcore-3.1&tabs=visual-studio– Leandro Angelo
You could add the *.csproj file of your project to confirm the version of . net that is used?
– tvdias
Sorry, I got the connection from the wrong project, this is the correct one from the json: "Connectionstring": "Host= localhost; user= user; pass=pass"
– Tácio Chateaubriand