Estoy haciendo una web multiidiomas y me sale un error que no se por que, aqui el codigo.
ublic Class pagebase
Inherits System.Web.UI.Page
'Protected Overrides Sub InitializeCulture()
' ' override virtual method InitializeCulture() to check if profile contains a user language setting
' Dim UserCulture As String = HttpContext.Current.Profile.GetPropertyValue("Pref erredCulture").ToString()
' If UserCulture <> "" Then
' ' there is a user language setting in the profile: switch to it
' Thread.CurrentThread.CurrentUICulture = New CultureInfo(UserCulture)
' Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(UserCulture)
' End If
'End Sub 'InitializeCulture
Protected Overrides Sub InitializeCulture()
' override virtual method InitializeCulture() to check if profile contains a user language setting
Dim UserCulture As String
If IsNothing(HttpContext.Current.Request.Cookies("Dan ielsCookie")) = True Then
UserCulture = ""
Else
Dim cookie As HttpCookie = HttpContext.Current.Request.Cookies("DanielsCookie ")
UserCulture = cookie.Item("DanielsCookie").ToString()
End If
If UserCulture <> "" Then
' there is a user language setting in the profile: switch to it
Thread.CurrentThread.CurrentUICulture = New CultureInfo(UserCulture)
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(UserCulture)
End If
End Sub
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
'' si la cookie no existe creala
'If IsNothing(HttpContext.Current.Request.Cookies("Dan ielsCookie")) = True Then
' Dim cookie As HttpCookie = HttpContext.Current.Request.Cookies("DanielsCookie ")
'End If
End Sub 'Page_Load
Protected Sub es_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Dim cookie As New HttpCookie("DanielsCookie")
cookie.value = "es"
Response.Cookies.Add(cookie)
' UserCulture = Request.Cookies("DanielsCookie").Value
Response.Redirect(Request.Url.LocalPath)
End Sub
Protected Sub en_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Dim cookie As New HttpCookie("DanielsCookie")
cookie.Value = "en"
Response.Cookies.Add(cookie)
' UserCulture = Request.Cookies("DanielsCookie").Value
Response.Redirect(Request.Url.LocalPath)
'HttpContext.Current.Profile.SetPropertyValue("Pre ferredCulture", "en")
''Force re-initialization of the page to fire InitializeCulture()
' SI la cookie no existe creala
End Sub
End Class
El error que me sale es en la linea
UserCulture = cookie.Item("DanielsCookie").ToString()
dice que Referencia a objeto no establecida como instancia de un objeto. NO estoy seguro si es uqe me falta configurar algo en el web.config quizas sea eso.... pero agradeceria mucho su ayuda, por lo demas el codigo y la implementacion funcionan bien,
Graciasss