Solved

Errors in ASP.NET machine.config and web.config

Posted on 2008-10-03
10
1,330 Views
Last Modified: 2008-10-05
Hi,

I recently put my site on the servers of a web hosting service.
The site included an SqlServer Express database named "Pictures"  and the remote database serve is called dbs5.dailyrazor.com.
The Welcome page has a link that sends me to a Login page... but once I log in I get the following error message:

Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.
----------------------
Source Error:

Line 137:    <membership>
Line 138:      <providers>
Line 139:        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
Line 140:      </providers>
Line 141:    </membership>


Source File: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config    Line: 139

------------------
The problem is that I located the error in the machine.config and changed the connection name to dbs5.dailyrazor.com
I also searched my web.config file and made sure there was no mention of "locaSqllServer", yet I keep getting the same message after going so far as to replace all the files on the remote server with the updated files on my machine.
I am attaching the connectionString that I have in my web.config:


 
<connectionStrings>
    <clear/>
    <add name="Pictures" connectionString="Server=dbs5.dailyrazor.com;Database=Pictures;Persist Security Info=True;User ID=myUserName;Password=myPassword"
   providerName="System.Data.SqlClient"/>
    <remove name="dbs5.dailyrazor.com"/>
    <add name="dbs5.dailyrazor.com" connectionString="dbs5.dailyrazor.com; Database=Pictures;Persist Security Info=True;User ID=myUserName;Password=myPassword" providerName="System.Data.SqlClient"/>
  </connectionStrings>

Open in new window

0
Comment
Question by:tariqanis
  • 5
  • 5
10 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 22633305
Why are you using machine.config to store a connection string? You have no access to machine.config on a shared server. You should use the web.config to store this connection string.
0
 

Author Comment

by:tariqanis
ID: 22635288
I did not put machine.config onthe remote server, but the error cites machine.config..... I don't know how it got on the remote server when I don't see it in my application......
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 22635318
The error is generic then as the asp.net looks for web.config and then for machine.config. Try to use correct connection strings and names in the web.config
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:tariqanis
ID: 22635394
The first time I opened  machine.config  was when I saw that error message which says that the error is in machine config.....

I thought that maybe it gets copied automatically with the rest of the application when I use the Copy Web Site utility that comes with ASP.NET.... And I don't see machine.config in the Solution Explorer, so I really don't understand how it was copied to the remote server!! In fact I don't see it on the remote server with the rest of my files... there is only a web.config.

By the way I am using Microsot Visual Studio Professional 3.5....
0
 

Author Comment

by:tariqanis
ID: 22637368
Do you see any thing wrong in the connectionString cited above?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 22637645
Machine.config is not copied with your website. It is installed by default along with the .NET framework.
I dont see anything wrong with this connectionstring except that i am not sure about the <clear /> tag. Remove that tag. How are you using the connectionstring in the code?
0
 

Author Comment

by:tariqanis
ID: 22638399
Only in some files do I use the database. The attachedcode is used each time I need to retrieve data from the database:
 
Dim connectionString As String = _
ConfigurationManager.ConnectionStrings("Pictures").ConnectionString
        Dim con As New SqlConnection(connectionString)
        Dim commTariq As SqlCommand
        Dim reader As SqlDataReader
        commTariq = New SqlCommand("Select Caption from Pics where Name='" & myTextBox.Text.ToString & "'", con)
        Try
            ' Open Connection
            con.Open()
            ' reader read command
            reader = commTariq.ExecuteReader()
            ' Display the requested data
            If reader.Read() Then
                captionLabel.Text = reader.Item("Caption")
            Else
                captionLabel.Text = "No text found"
 
            End If
 
            ' Close dataReader
            reader.Close()
 
        Finally
            ' close connection
            con.Close()
        End Try

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 22638470
everything seems ok with the code.
0
 

Author Comment

by:tariqanis
ID: 22638798
Well, I deleted the <Clear/> tag and now have the following error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)


0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 22641801
Now you need to make sure that the connectionstring is valid according to the SQL Server configuration you have. Verify that the server name, instance name, and database names are valid and that the SQL Server does allow remote connections.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question