1

I am learning ASP.NET framework. I have created a simple To Do List with React.js on the front end, and ASP.NET Core on the backend. It seems I am connecting to the database with no problems. But I have added a simple table to the server for the purposes of testing the connection which look something like this: 1 Create a To Do List but when I launch the app on localhost, nothing is displayed, as depicted in this picture loading..., which suggests the back end is not functioning properly. Here is my connection string: "DBConString": "jdbc:sqlserver://localhost;database=master" and other relevant connection info```

        {
            services.AddControllersWithViews();
            var ConnectionString = Configuration.GetConnectionString("DBConString");
            services.AddDbContext<ToDoListDBContext>(options =>
                options.UseSqlServer(ConnectionString));
            services.AddMvc();
            services.AddCors();```

    app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=ToDosController}/{action=Index}/{id?}");
            });

Also some screenshots that show my successful connection to the database in my IDE: successful connection to database in Rider If anyone could share some insight into why this is not working, it'd be much appreciated!

3
  • Have you tried debugging the application to see what the application is doing? Follow through on your database request and see if you're getting anything in return. Commented May 13, 2021 at 17:51
  • 1
    You likely don't want to be connecting to your master SQL Server database as your connection string indicates. Commented May 13, 2021 at 17:51
  • As Timothy noted, you should not be using 'master' as your schema. You will want to create a new database to hold your table. With that said, your connection string seems to be a little off? It should look more like so: "data source=localhost;initial catalog=master;integrated security=True;" 'integrated security' unless you have SQL Server Authentication - with a specific user/pass set (e.g., sa and sa's password in your case to use master). You'll also want to take a look at this to use a transient scope: stackoverflow.com/questions/41923804/… Commented May 13, 2021 at 18:35

1 Answer 1

2

ConnectionStrings in .NET Core have a special format that needs to be followed.

Take a look here to see what you need: https://www.connectionstrings.com/sql-server/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.