c# - Strange issues with WebSecurity.InitializeDatabaseConnection() and Azure hosting -


this 1 weird enough make me think overlooking obvious here.

i have asp.net mvc4 application sql server 2008 database. using ef code first, code first migrations. mvc membership using simplemembershipprovider.

here info regarding current state of things:

  1. the database on azure, , has latest migration run on it.
  2. i can connect database using connection string have on file, there no issue connection string can see.
  3. this has been happening intermittently throughout various publishes of site.
  4. i calling websecurity.initializedatabaseconnection("defaultconnection", "users", "userid", "username", autocreatetables: true); in global.asax
  5. my ip address allowed on database server.

here application_start() method in global.asax:

protected void application_start()     {         websecurity.initializedatabaseconnection("defaultconnection", "users", "userid", "username", autocreatetables: true);         //seedmembership();         arearegistration.registerallareas();          database.setinitializer<ptcontext>(null);          webapiconfig.register(globalconfiguration.configuration);         filterconfig.registerglobalfilters(globalfilters.filters);         routeconfig.registerroutes(routetable.routes);         bundleconfig.registerbundles(bundletable.bundles);         authconfig.registerauth();     } 

if publish azure, gives me error:

login failed user 'username'. session has been assigned tracing id of '95f84d15-0e0c-47f8-bc04-3ae7febf5de8'. provide tracing id customer support when need assistance. 

'username' here username of sql server have on azure.

now strange part. if comment out websecurity line so:

protected void application_start()     {         //websecurity.initializedatabaseconnection("defaultconnection", "users", "userid", "username", autocreatetables: true);         //seedmembership();         arearegistration.registerallareas();          database.setinitializer<ptcontext>(null);          webapiconfig.register(globalconfiguration.configuration);         filterconfig.registerglobalfilters(globalfilters.filters);         routeconfig.registerroutes(routetable.routes);         bundleconfig.registerbundles(bundletable.bundles);         authconfig.registerauth();     } 

and if publish, me login page (which default start page, thing), log in, error:

you must call "websecurity.initializedatabaseconnection" method  before call other method of "websecurity" class. call should placed in _appstart.cshtml file in root of site. 

this error not surprising, since using websecurity handle login , membership stuff.

you can see how kind of lose-lose here me. assumption websecurity.init..() line causing first error thrown, , obvious lack of having code there in app_start method causing second error. don't know doing wrong here. help?


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -