Error al encryptar web config

02/05/2007 - 12:14 por verci | Informe spam
Hola

Estoy tratando de encryptar la sección connection string del web.config en
mi website, pero me aparece este error, gracias de antemano por su ayuda.


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 entry 'SiteDB' has already been added.

Source Error:

Line 50: </location>
Line 51: <connectionStrings>
Line 52: <add name="SiteDB" connectionString="Data
Source=Movil1\Movil1;Initial Catalog=Inventory;User ID=sa; Password=xxx"
providerName="System.Data.SqlClient"/>


Source File: C:\Documents and Settings\verci\My Documents\Visual Studio
2005\testsite\web.config Line: 52



Este es el código que uso en mi codebehind page.

Imports System

Imports System.Web.Configuration

Imports System.IO

Imports System.Data

Imports System.Configuration

Imports System.Collections

Imports System.Web

Imports System.Web.Security

Imports System.Web.UI

Imports System.Web.UI.WebControls

Imports System.Web.UI.WebControls.WebParts

Imports System.Web.UI.HtmlControls

Partial Class Test101

Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

ProtectSection("connectionStrings", "DataProtectionConfigurationProvider")

End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click

UnProtectSection("connectionStrings")

End Sub

Private Sub ProtectSection(ByVal sectionName As String, ByVal provider As
String)

Dim config As Configuration =
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

Dim section As ConfigurationSection = config.GetSection(sectionName)

If Not (section Is Nothing) AndAlso Not
section.SectionInformation.IsProtected Then

section.SectionInformation.ProtectSection(provider)

config.Save()

End If

End Sub

Private Sub UnProtectSection(ByVal sectionName As String)

Dim config As Configuration =
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

Dim section As ConfigurationSection = config.GetSection(sectionName)

If Not (section Is Nothing) AndAlso section.SectionInformation.IsProtected
Then

section.SectionInformation.UnprotectSection()

config.Save()

End If

End Sub



End Class

Preguntas similare

Leer las respuestas

#1 Victor B.
02/05/2007 - 13:00 | Informe spam
Parece que en tu web.config ya tienes otra línea en la que has puesto el
nombre SiteDB. Al menos es lo que interpreto del mensaje de error:
Parser Error Message: The entry 'SiteDB' has already been added.


Víctor B.
Desarrollador independiente

"verci" escribió en el mensaje
news:
Hola

Estoy tratando de encryptar la sección connection string del web.config en
mi website, pero me aparece este error, gracias de antemano por su ayuda.


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 entry 'SiteDB' has already been added.

Source Error:

Line 50: </location>
Line 51: <connectionStrings>
Line 52: <add name="SiteDB" connectionString="Data
Source=Movil1\Movil1;Initial Catalog=Inventory;User ID=sa; Password=xxx"
providerName="System.Data.SqlClient"/>


Source File: C:\Documents and Settings\verci\My Documents\Visual Studio
2005\testsite\web.config Line: 52



Este es el código que uso en mi codebehind page.

Imports System

Imports System.Web.Configuration

Imports System.IO

Imports System.Data

Imports System.Configuration

Imports System.Collections

Imports System.Web

Imports System.Web.Security

Imports System.Web.UI

Imports System.Web.UI.WebControls

Imports System.Web.UI.WebControls.WebParts

Imports System.Web.UI.HtmlControls

Partial Class Test101

Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

ProtectSection("connectionStrings", "DataProtectionConfigurationProvider")

End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click

UnProtectSection("connectionStrings")

End Sub

Private Sub ProtectSection(ByVal sectionName As String, ByVal provider As
String)

Dim config As Configuration =
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

Dim section As ConfigurationSection = config.GetSection(sectionName)

If Not (section Is Nothing) AndAlso Not
section.SectionInformation.IsProtected Then

section.SectionInformation.ProtectSection(provider)

config.Save()

End If

End Sub

Private Sub UnProtectSection(ByVal sectionName As String)

Dim config As Configuration =
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

Dim section As ConfigurationSection = config.GetSection(sectionName)

If Not (section Is Nothing) AndAlso section.SectionInformation.IsProtected
Then

section.SectionInformation.UnprotectSection()

config.Save()

End If

End Sub



End Class


Respuesta Responder a este mensaje
#2 verci
02/05/2007 - 15:04 | Informe spam
Esa es la impresión, pero no tengo otra línea, es la única!!! , tengo
varios días con esta situación y no encuentro el porque del error.


"Victor B." wrote in message
news:
Parece que en tu web.config ya tienes otra línea en la que has puesto el
nombre SiteDB. Al menos es lo que interpreto del mensaje de error:
Parser Error Message: The entry 'SiteDB' has already been added.


Víctor B.
Desarrollador independiente

"verci" escribió en el mensaje
news:
Hola

Estoy tratando de encryptar la sección connection string del web.config
en mi website, pero me aparece este error, gracias de antemano por su
ayuda.


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 entry 'SiteDB' has already been added.

Source Error:

Line 50: </location>
Line 51: <connectionStrings>
Line 52: <add name="SiteDB" connectionString="Data
Source=Movil1\Movil1;Initial Catalog=Inventory;User ID=sa; Password=xxx"
providerName="System.Data.SqlClient"/>


Source File: C:\Documents and Settings\verci\My Documents\Visual Studio
2005\testsite\web.config Line: 52



Este es el código que uso en mi codebehind page.

Imports System

Imports System.Web.Configuration

Imports System.IO

Imports System.Data

Imports System.Configuration

Imports System.Collections

Imports System.Web

Imports System.Web.Security

Imports System.Web.UI

Imports System.Web.UI.WebControls

Imports System.Web.UI.WebControls.WebParts

Imports System.Web.UI.HtmlControls

Partial Class Test101

Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

ProtectSection("connectionStrings",
"DataProtectionConfigurationProvider")

End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click

UnProtectSection("connectionStrings")

End Sub

Private Sub ProtectSection(ByVal sectionName As String, ByVal provider As
String)

Dim config As Configuration =
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

Dim section As ConfigurationSection = config.GetSection(sectionName)

If Not (section Is Nothing) AndAlso Not
section.SectionInformation.IsProtected Then

section.SectionInformation.ProtectSection(provider)

config.Save()

End If

End Sub

Private Sub UnProtectSection(ByVal sectionName As String)

Dim config As Configuration =
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

Dim section As ConfigurationSection = config.GetSection(sectionName)

If Not (section Is Nothing) AndAlso
section.SectionInformation.IsProtected Then

section.SectionInformation.UnprotectSection()

config.Save()

End If

End Sub



End Class






Respuesta Responder a este mensaje
#3 Javier Romero
03/05/2007 - 01:03 | Informe spam
A lo mejor tienes un webconfig superior a tu aplicación?
es decir tu aplicación está en : http://localhost/TuAplicacion.
existe en http://localhost algún web.config con esa llave?

Recuerda que la configuración se hereda desde la aplicación madre ...

Saludos...


Javier Romero A., MCAD
Temperamental .NET Developer.
http://javier-romero.com


"verci" wrote in message
news:
Esa es la impresión, pero no tengo otra línea, es la única!!! , tengo
varios días con esta situación y no encuentro el porque del error.


"Victor B." wrote in message
news:
Parece que en tu web.config ya tienes otra línea en la que has puesto el
nombre SiteDB. Al menos es lo que interpreto del mensaje de error:
Parser Error Message: The entry 'SiteDB' has already been added.


Víctor B.
Desarrollador independiente

"verci" escribió en el mensaje
news:
Hola

Estoy tratando de encryptar la sección connection string del web.config
en mi website, pero me aparece este error, gracias de antemano por su
ayuda.


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 entry 'SiteDB' has already been added.

Source Error:

Line 50: </location>
Line 51: <connectionStrings>
Line 52: <add name="SiteDB" connectionString="Data
Source=Movil1\Movil1;Initial Catalog=Inventory;User ID=sa; Password=xxx"
providerName="System.Data.SqlClient"/>


Source File: C:\Documents and Settings\verci\My Documents\Visual Studio
2005\testsite\web.config Line: 52



Este es el código que uso en mi codebehind page.

Imports System

Imports System.Web.Configuration

Imports System.IO

Imports System.Data

Imports System.Configuration

Imports System.Collections

Imports System.Web

Imports System.Web.Security

Imports System.Web.UI

Imports System.Web.UI.WebControls

Imports System.Web.UI.WebControls.WebParts

Imports System.Web.UI.HtmlControls

Partial Class Test101

Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

ProtectSection("connectionStrings",
"DataProtectionConfigurationProvider")

End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click

UnProtectSection("connectionStrings")

End Sub

Private Sub ProtectSection(ByVal sectionName As String, ByVal provider
As String)

Dim config As Configuration =
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

Dim section As ConfigurationSection = config.GetSection(sectionName)

If Not (section Is Nothing) AndAlso Not
section.SectionInformation.IsProtected Then

section.SectionInformation.ProtectSection(provider)

config.Save()

End If

End Sub

Private Sub UnProtectSection(ByVal sectionName As String)

Dim config As Configuration =
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

Dim section As ConfigurationSection = config.GetSection(sectionName)

If Not (section Is Nothing) AndAlso
section.SectionInformation.IsProtected Then

section.SectionInformation.UnprotectSection()

config.Save()

End If

End Sub



End Class










Respuesta Responder a este mensaje
#4 verci
13/05/2007 - 21:41 | Informe spam
Hola Javier

Tenias razón , ya quedo.

Saludos

"Javier Romero" wrote in message
news:
A lo mejor tienes un webconfig superior a tu aplicación?
es decir tu aplicación está en : http://localhost/TuAplicacion.
existe en http://localhost algún web.config con esa llave?

Recuerda que la configuración se hereda desde la aplicación madre ...

Saludos...


Javier Romero A., MCAD
Temperamental .NET Developer.
http://javier-romero.com


"verci" wrote in message
news:
Esa es la impresión, pero no tengo otra línea, es la única!!! , tengo
varios días con esta situación y no encuentro el porque del error.


"Victor B." wrote in message
news:
Parece que en tu web.config ya tienes otra línea en la que has puesto el
nombre SiteDB. Al menos es lo que interpreto del mensaje de error:
Parser Error Message: The entry 'SiteDB' has already been added.


Víctor B.
Desarrollador independiente

"verci" escribió en el mensaje
news:
Hola

Estoy tratando de encryptar la sección connection string del web.config
en mi website, pero me aparece este error, gracias de antemano por su
ayuda.


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 entry 'SiteDB' has already been added.

Source Error:

Line 50: </location>
Line 51: <connectionStrings>
Line 52: <add name="SiteDB" connectionString="Data
Source=Movil1\Movil1;Initial Catalog=Inventory;User ID=sa;
Password=xxx"
providerName="System.Data.SqlClient"/>


Source File: C:\Documents and Settings\verci\My Documents\Visual Studio
2005\testsite\web.config Line: 52



Este es el código que uso en mi codebehind page.

Imports System

Imports System.Web.Configuration

Imports System.IO

Imports System.Data

Imports System.Configuration

Imports System.Collections

Imports System.Web

Imports System.Web.Security

Imports System.Web.UI

Imports System.Web.UI.WebControls

Imports System.Web.UI.WebControls.WebParts

Imports System.Web.UI.HtmlControls

Partial Class Test101

Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

ProtectSection("connectionStrings",
"DataProtectionConfigurationProvider")

End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button2.Click

UnProtectSection("connectionStrings")

End Sub

Private Sub ProtectSection(ByVal sectionName As String, ByVal provider
As String)

Dim config As Configuration =
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

Dim section As ConfigurationSection = config.GetSection(sectionName)

If Not (section Is Nothing) AndAlso Not
section.SectionInformation.IsProtected Then

section.SectionInformation.ProtectSection(provider)

config.Save()

End If

End Sub

Private Sub UnProtectSection(ByVal sectionName As String)

Dim config As Configuration =
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)

Dim section As ConfigurationSection = config.GetSection(sectionName)

If Not (section Is Nothing) AndAlso
section.SectionInformation.IsProtected Then

section.SectionInformation.UnprotectSection()

config.Save()

End If

End Sub



End Class










email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida