Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-10-03
10
Medium Priority
?
1,345 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
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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 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