Can't connect to database unless I use a password?

Discussion in 'ASP.NET / ASP.NET Core' started by xaisoft, Feb 5, 2010.

  1. I can't connect to my mvc application unless I use a password in the connection string. I tried putting the following in my web.config file:

    "Data Source=tcp:sql2k801.discountasp.net;Initial Catalog=Database;User ID=User;"

    but that does not work. It only works when I put a Password in like so:

    "Data Source=tcp:sql2k801.discountasp.net;Initial Catalog=Database;User ID=User;Password=password;"

    Do I have to put my login credentials, username and password in the web.config or is there a way around this?
     
  2. Yes, you cant login without credentials.
     
  3. mjp

    mjp

    I really don't think you would want to allow connections to your database without a password. Do you want to give access to anyone who can guess or figure out the username? Not cool.

    No one can view of download your web.config via http, so you shouldn't have to worry about that. But every web site in the world that uses a database backend has to have a password in a readable file somewhere.
     
  4. mjp,

    The first part of your answer is not what I meant, but the second part was. I was just curious if their was a way to use the password without storing it in the web.config file. If someone has access to my ftp information, can't they just ftp in and view my connection string from there. I guess I can also encrypt the connection string and decrypt it in code. Right?

    Thanks for the help.
     
  5. mjp

    mjp

    Yes you can.
     
  6. mjp

    mjp

    Ha. Like Chuck said!
     

Share This Page