c# - HttpResponseMessage parameters received after constructor is called -
i have api controller when called client passes database credentials.
public class foremancontroller : apicontroller { static sqlconnectionstringbuilder connectionstring = new sqlconnectionstringbuilder (); public foremancontroller() { //database calls connection string } public void get(string datasource, string initialcatalog, string userid, string password) { connectionstring.datasource = datasource; connectionstring.initialcatalog = initialcatalog; connectionstring.userid = userid; connectionstring.password = password; } }
the method working fine , can see credentials being passed via client code:
static httpclient client = new httpclient(); httpresponsemessage resp = client.getasync("api/foreman?datasource=dxdv&initialcatalog=q19410&userid=tunld&password=did").result;
my problem constructor in apicontroller runs before method database calls fail because of null connection string.
how parameters pass before constructor?
Comments
Post a Comment