Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-03
10
Medium Priority
?
1,350 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 2000 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

Technology Partners: 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

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…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Loops Section Overview
Suggested Courses

926 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