Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
869 views
in Technique[技术] by (71.8m points)

deployment - Format of the initialization string does not conform to specification starting at index 0

I have an ASP.Net MVC application which runs fine on my local development machine. But when deployed to IIS7 gives the following error when trying to log in:

Format of the initialization string does not conform to specification starting at index 0

Most people who post this error resolve it by changing their connection string in some way. However my connection string on the local and deployed application are the same. The connection string is like this:

<add name="ApplicationServices" connectionString="Data Source=*server**instance*;Initial Catalog=*database*;Integrated Security=True;"
      providerName="System.Data.SqlClient" />

What is causing this error in my case?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Format of the initialization string does not conform to specification starting at index 0

Web.config :

<connectionStrings>
    <add name="TestDataConnectionString" connectionString="Data Source=.SQLExpress;Initial Catalog=TestData;User ID=satest;Password=satest"
     />
  </connectionStrings>

In aspx.cs Page the code must be written in the below format :

SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["TestDataConnectionString"].ToString());

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...