質問

Situation is like this: I have two projects. One Asp.net and one project which does all data related stuff with database. I keep my connectionstring in a seperate encrypted XML file. Now instead of requesting all data constantly from sql. I want to use SqlCacheDependency to gain performance. If I follow the instruction they advice me to add a database name in web.config.

<caching>
  <sqlCacheDependency enabled ="true">
    <databases>
      <add name="dbName"  connectionStringName="connectionstringName" />
    </databases>
  </sqlCacheDependency>
</caching>

Is there any way to this in code. Like in Application Application_Start() event in global.asax file where I can link to a custom method that provides me that connectionstring?

Thanks in advance

役に立ちましたか?

解決

Thanks to David Gardiner's work around. I found in the following post.

How do I set a connection string config programatically in .net?

I've put it in the Global.asax application load event. Now I can from my sqlcachedependency section in web.config. to that existing connectionStringName from the connectionstring collection.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top