Home Dashboard Directory Help
Search

ASP.NET MVC 4 - Default connection string improperly escaped by Nick Strupat


Status: 

Closed
 as Fixed Help for as Fixed


1
0
Sign in
to vote
Type: Bug
ID: 740623
Opened: 5/4/2012 11:06:51 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
1
Workaround(s)
view
0
User(s) can reproduce this bug

Description

The initialization of the connection string in a new ASP.NET MVC 4 project is the following

Database.DefaultConnectionFactory = new SqlConnectionFactory("Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True");

The "\v" is not escaped and will yield an incorrect connection string. This string should be escaped properly. I have provided two possible solutions in the 'expected results' section below.
Details
Sign in to post a comment.
Posted by Microsoft on 5/12/2012 at 5:26 PM
Hi Nick,

Thanks for filing this bug. We have corrected this error by properly escaping the \v. It was a last minute change for the Beta and we missed it! For now there are two workarounds I can think of:
1. Add an extra \ to it, so that it becomes \\v
2. Prefix the string with an @ so that it looks like @"connection string here"

Our next release will have this issue corrected.

Thanks,
Eilon
Posted by MS-Moderator10 [Feedback Moderator] on 5/7/2012 at 8:54 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by MS-Moderator01 on 5/4/2012 at 11:43 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Nick Strupat on 5/4/2012 at 11:07 AM
Change the connection string to

Database.DefaultConnectionFactory = new SqlConnectionFactory("Data Source=(localdb)\\v11.0; Integrated Security=True; MultipleActiveResultSets=True");

OR

Database.DefaultConnectionFactory = new SqlConnectionFactory(@"Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True");

to properly escape the "(localdb)\v11.0" section