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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

asp.net connection string value lost

I setup my connection string in my web.config.

I have a custom membership provider that defines it in the initialize....
connStr = config("connectionString")

When I call the validateuser(), it hits the connection string okay.

I call the exact same code in my GetUser(), and now my connection string is empty.

both have these at the top:
        Using conn As New SqlConnection(connStr)

What is happening? Why is it now empty for this function?
thanks.
0
Starr Duskk
Asked:
Starr Duskk
  • 6
1 Solution
 
spprivateCommented:
connStr = config("connectionString")
I assume this connstr variable scope is not public or class level.You would have declared it in a method level and hence you are not getting the value.
Declare the connStr initialization on a class level and then use it.
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
It IS class level:

Public Class CustomMembershipProvider
    Inherits MembershipProvider

    Private connStr As String
    Private comm As New SqlClient.SqlCommand
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
I declared it Public and that didn't fix it either.

I do notice stepping through it, that the Initialize is not called on the GetUser. It is called on the ValidateUser, but not the GetUser....

???
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
I take that back. When I log in, it hits the validateuser, but putting a breakpoint on the initialize, I never see it hit that.

Although, the ValidateUser does have a valid connstr.
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
Hmmm. I have old backup copies that are hitting the initialize on log in when I debug, but my latest version is not.

What could be the reason?
thanks.
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
Okay, I notice that when I put code to call my getuser in my pre_init on my master page, it never hits the initialize. I'll have to look at that.

Meanwhile, if anyone has any thoughts, would appreciate it.

thanks.
0
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
I need to create a new question on this.

My problem is that my initialize is not firing. So I need to ask about that.

thanks.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now