Set connection string of membership dynamically from code

前端 未结 2 1202
慢半拍i
慢半拍i 2020-12-19 09:41

I am having a .net web application which uses membership for users validations. The membership has a definition in the web.config file and refer to a connection string in th

2条回答
  •  春和景丽
    2020-12-19 10:23

    There is a much easier solution to this.

    1. Create a child class extending SqlMembershipProvider class.
    2. Override Initialize method
    3. Set connectionString property config["connectionString"]
    4. Let the base.Initialize logic continue
    5. In the web.config file, instead of SqlMembershipProvider, use your custom class. (if you give it a different name, make sure to set the defaultProvider attribute to match that)

提交回复
热议问题