I've read through a number of SO questions on this topic, but all seem to be dealing with where you should put this call.
My problem is different: I have already done the WebSecurity.InitializeDatabaseConnection()
call, and have set breakpoints so I know it's been executed. But I still get the invalid operation exception
saying I have to call it.
Unlike most of the other questions which are encoutering it in an MVC controller action, I'm encountering it an HttpModule
I have written to accomplish Authentication for a REST WebAPI controller. The Init call contains the WebSecurity.InitializeDatabaseConnection
call. The OnAuthenticationRequest
method then extracts username and password information from the request's Authorization header, and calls the ValidateUser
method of the SimpleMembershipProvider
. This is where I get the exception
You must call the
WebSecurity.InitializeDatabaseConnection
method before you call any other method of theWebSecurity
class.
So
a) why am I getting this exception when I have already fulfilled the conditions not to get it.
b) what can be done about it?