Wednesday, March 28, 2012

Problems hitting SqlServer from Global.asax Application_Start

Hi,

In my application I Application_Start event in Global.asax I am wanting to populate an Application state variable to hold data from a database.

I can use the exact code elsewhere in the application but when I try to open my SqlConnection object I get the error "SQL Server does not exist or access denied."

I'm using NT security and impersonation.

I've put a trace on the server and my user name isn't appearing as trying anything so it is as if it cannot find the server.

Are there any issues with trying to open a connection from Application_Start?

Thanks.

Can you post your source code here?

|||There was an atricle about this in the latest MSDN magazine. Basically, asp.net won't do impersonation in the application start event. Your best bet is to grab the data the first time that you need it in regular code.

No comments:

Post a Comment