Connecting to database in ASP MVC3 application with IIS
I've had some problems connecting with my database in a web application. The database is a .mdf and sits in my App_Data Folder. I'm using IIS 7.5 to run and debug my website.
I got following error:
Troubleshoot Error: An attempt to attach an auto-named database for file database location failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
I came up with this solution:
http://www.dotnetfunda.com/articles/article905-troubleshoot-error-an-attempt-to-attach-an-autonamed-database-for-file-l-.aspx
BUT this involves leaving my computer's login and password wide open in the web.config. As you may开发者_StackOverflow understand, I'm not too happy about that... Is there a way to hide my password from the web.config or solve this problem otherwise? Thanks.
Assuming your storing it in connection strings - since ASP.NET 2.0, you can encrypt any section...
run from your site root..
G:\content\snippet-site>C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis -pef "connectionStrings"
This should do the trick.
A bit more info... http://weblogs.asp.net/scottgu/archive/2006/01/09/434893.aspx
精彩评论