none
Overriding the connection string in Membership and Role providers at runtime RRS feed

  • Question

  • I am currently developing a new version of an application.

    The current version of the application is used by 5 clients each with a different SQL Server databases all on the same server. This means that currently we have 5 websites (one for each client) configured in IIS7 that are all using the same software.

    In the new version of the application I would like to to use one website that can use any of the 5 databases depending on the client selected by selecting the client before the user signs in to the application.

    I already have 5 connection strings in the web.config and can select the one relevant to the client - that was the easy part. I now need to ensure that the Membership and Roles providers use the same connection string by either 1, using custom providers (complex) or by 2, overriding the connection string in the default provider (simpler).

    I have seen many Visual C examples on various web forums that give a solution to my problem, but as I have never used C, I am finding it difficult to produce a VB.Net version of the code.

    Could you please show me an a VB.Net example of achieving a solution to my problem?

    Thanks in advance,

    Gareth

    • Edited by Gareth Bond Thursday, November 8, 2018 6:22 AM
    Thursday, November 8, 2018 6:21 AM

All replies

  • I have seen many Visual C examples on various web forums that give a solution to my problem, but as I have never used C, I am finding it difficult to produce a VB.Net version of the code.

    Like posters in the forum are not multiple language developers?

    Post a C# link and see if someone can convert it to VB.NET.

    On the other hand, you have VB and C# posters in the ASP.NET forums, since that is really what you are using ==  a Web based ASP.NET solution.

    http://forums.asp.net/

    Thursday, November 8, 2018 1:37 PM
  • Hi Gareth,

    I took a look at the official documentation, the first part talks about Required Provider Members, the first one is the Initialize method, then you should wether to find the call to the Initialize method in your code, or to create a custom Membership Provider and override the Initialize method, can you try these options?

    Hope it helps!

    Good Coding;

    Thursday, November 8, 2018 4:37 PM