Tonight I was converting an ASP.NET 2.0 Website to a Web Application Project. There is a nice step-by-step guide that I was using to walk me through the process. I ran into troubles as soon as I ran the “Convert to Web Application” menu.
I tracked the trouble down to four files in the project. All of them were failing with this message.
Generation of designer file failed: The expression prefix “ConnectionStrings” was not recognized. Please correct the prefix or register the prefix in the <expressionBuilders> section of configuration.
The first place I looked was a dead end. I looked in the web.config, thinking that was the configuration file in the error message. Wrong!
Next I looked at the html on one of the problem pages.
<asp:SqlDataSource ID="dsUsers" runat="server" ConnectionString="<%$ ConnectionStrings:aspnetdbConnectionString %>"
There was the ConnectionStrings text!
The Fix
- Cut everything between the quotes for value of the ConnectionString attribute.
- Do the same for any other ConnectionString attributes on the same page.
- Run the “Convert to Web Application” for the current page.
- Restore the ConnectionString value and save the file.