Solved

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

Posted on 2008-10-03
10
1,332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

752 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