Azure website exception: Initialization string format does not meet specification starting with index 0

I have an Azure site that I use to host my MVC + Entity Framework project. When I run the site locally using the same connection to my Azure SQL database, everything works fine, but when I deploy the site to my Azure Website, I get the following error:

The format of the initialization string does not match the specification starting at index 0.

I followed the steps in several other posts and added a connection string to the error that occurred, and this is what the connection string displays:

Server=tcp:abcde1fgh2.database.windows.net,1433;Database=SalesLeads;User ID=username_test@abcde1fgh2 ;Password=Password;Trusted_Connection=False;Encrypt=True;Connection Timeout=30; 

This string corresponds to the connection string that is used locally.
Why will this work locally with the same string, but not remotely?

EDIT

Here is the full web.config for the site:

 <?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=301880 --> <configuration> <configSections> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections> <connectionStrings> <add name="DefaultConnection" connectionString="Server=tcp:abcde1fgh2.database.windows.net,1433;Database=SalesLeads;User ID=username_test@abcde1fgh2 ;Password=Password;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.SqlClient" /> </connectionStrings> <appSettings> <add key="webpages:Version" value="3.0.0.0" /> <add key="webpages:Enabled" value="false" /> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings> <system.web> <authentication mode="None" /> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" maxRequestLength="102400" /> </system.web> <system.webServer> <modules> <remove name="FormsAuthentication" /> </modules> <handlers> <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> <remove name="OPTIONSVerbHandler" /> <remove name="TRACEVerbHandler" /> <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> </handlers> </system.webServer> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /> <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.AspNet.SignalR.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.1.2.0" newVersion="2.1.2.0" /> </dependentAssembly> </assemblyBinding> </runtime> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="v12.0" /> </parameters> </defaultConnectionFactory> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> </providers> </entityFramework> </configuration> 
+6
source share
3 answers

You must FTP to your Azure site, and also check your connection string in web.config .

When you publish your site, your web.config converted / modified by Azure, so it may happen that this process messes up something with your connection string, which leads to this error. For example, if you configure the connection string through a web portal, it is possible that the encoding is confused during copying or pasting, etc.

+2
source

10/2/17 - Using Azure Web App + ASP.NET MVC (.NET 4.6.1) + Entity Framework (latest version). For a quick fix, I put the connection string in the code and worked:

 public class MyDbContext : DbContext { private const string connectionString = "Server=tcp:MYDB.database.windows.net,1433;Initial Catalog=MYDBNAME;Persist Security Info=False;User ID=MYUSERID;Password=MYPW;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"; public MyDbContext() : base(connectionString) { } } 
+1
source

According to some studies, I found that the error occurs in the following possible cases:

Opportunity 1 . You are probably using the wrong DbConnection class. If you use Access, be sure to use OleDbConnection , not SqlConnection ... and vice versa.

Opportunity 2 . This indicates that the problem is with the database, but the problem is with the APP POOL identifier for running websites in IIS. There is some information on what this means here in Application Pool Identifiers . We noticed that we tend not to see the problem on sites that are configured more old-fashioned, namely to create a new IUSR user account on the server, and then add this user to the IIS user group, and then set the site to use this user, not for the APP POOL identifier. Ensure a password expiration problem is sorted by your primary administrator account on the server. And if this does not solve the problem, create a new Windows “IUSR” user account and configure the site to use this, rather than the APP POOL ID. In public hosting this may not be possible, but dealing with expiration of the administrator password is what the host can solve.

0
source

Source: https://habr.com/ru/post/982502/


All Articles