0

i created a simple webapi and a simple webpage with different ports to register a new user. when my webpage consume the webapi. it always show This database was create. and it works fine with local host from the same webapi project. i already added my IIS application pool to the mysql security already.

Error 500

CREATE TABLE permission denied in database 'atestDB'

i noticed that if i remove this line in the connection string. it will works fine.

Integrated Security=True

so my question is. can i go without integrated in my sql connection string?

web page

 $(document).ready(function()
    {
        $('#btnregister').click(function ()
        {

            RegisterBindingModel.Email = $('#Email').val();
            RegisterBindingModel.Password = $('#Password').val();
            RegisterBindingModel.ConfirmPassword = $('#ConfirmPassword').val();
            debugger
            $.ajax({
                url: 'http://www.azapi.com:81/api/account/register',
                type:'Post',
                contentType: "application/json; charset=UTF-8",
                data: JSON.stringify(RegisterBindingModel),
                success: function(data) {
                    debugger
                    alert(data)
                },
                error: function (err) {

                    alert(err.status)
                }

            })

        })

    }
    )
</script>

webapi

using standard registeration api from .net with cros enabled.

 EnableCorsAttribute cors = new EnableCorsAttribute("*","*","*");
        config.EnableCors(cors);
MVC newbie
  • 579
  • 3
  • 9
  • 26
  • When you created your database, did you create a login for that database that has admin privledges? If not, do so and replace `Integrated Security=True` with your username and password that you created for admin privledges to that database – Grizzly Aug 10 '17 at 13:26
  • Your connection string should look something like this: `` – Grizzly Aug 10 '17 at 13:29
  • yes i have admin account for database. sa. the code works find if i port the registration page to webapi project. i will not get this error when using localhost – MVC newbie Aug 10 '17 at 14:28
  • this is my connection string` ` `` – MVC newbie Aug 10 '17 at 14:31
  • i am just doing a normal insert from registration api only – MVC newbie Aug 10 '17 at 14:32
  • If you use a Username and password.. then don't include `Integrated Security` – Grizzly Aug 10 '17 at 14:32

1 Answers1

0

You can set Integrated Security to false. If you set it to false the ID and password in the connection are used to athenticate you. If you do so keep in mind that it's not a good idea (actually it's a very bad idea) to have sensitiv data, like passwords, hard coded. There are a few ways to avoid this. If you like to see two ways check out the answer to this post.

T. Jung
  • 3,327
  • 3
  • 11
  • 19
  • 1
    When you use EF and create your connection string, you're asked if you would like to include sensitive data in the connection string. The OP could just click "Don't include sensitive information" – Grizzly Aug 10 '17 at 13:34
  • Yes your're right. I've updated my answer and linked a post which explains how to provide the data if it's not included. – T. Jung Aug 10 '17 at 13:46
  • whole project was default.i didnt not create anything yet.The database was created when i create new record – MVC newbie Aug 10 '17 at 14:30
  • As i said. You can set Integrated Security to false. Instead of using the windows athentification it will use the ID and password in your connection string. – T. Jung Aug 10 '17 at 14:33
  • any draw back on setting to false? – MVC newbie Aug 10 '17 at 14:39
  • If you're working with a team the only problem is that every developer knows the password and username for the db. Otherwise nothing comes into my mind at the moment. – T. Jung Aug 10 '17 at 14:47