Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

SqlCacheDependency - repost in hopes of a reply

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adrian Parker - 20 Oct 2005 17:31 GMT
I've got the standard SqlCacheDependency working just fine , ie. I've
defined (and encrypted) the connectionStrings section in the web.config, and
I've also defined an an sqlCacheDependency in the caching section. So, in my
code I add an item to the cache with an sqlCacheDependency, referencing the
named sqlCacheDependency in the web.config and the database table it is to
be based on (have enabled notificiations for that table).  Fine.

What I'd like to do however is too dynamically build the connection strings
and define the sqlCacheDependencies dynamically as well (ie not in the
web.config), although thats thats too important, it's the connection string
I'm really interested in.

I've been on the web, even had a look at the .net classes using the
reflector.exe. I've tried creating a SqlCacheDependencyDatabase dynamically
but when I try and reference it by name in the constructor for
sqlCacheDependency it can't find it because it's only looking at ones that
have been loaded from the web.config.

The reason the connection strings have to be dynamically created is that the
app is deployed on several different client sites, and they have control
over the db server and the db name, but we need to keep the user name and
password to ourselves.  We already build our connection strings dynamically
for normal db stuff.  We have a custom section within the web config where
the client puts the db server and the db name.

It doesn't seem like such an strange thing to want to do, either I'm missing
something or it's harder than it should be.
Guadala Harry - 20 Oct 2005 20:29 GMT
Maybe I'm just easily confused - but are you asking about [how to
dynamically encrypt a dynamically created connection string], or how to
[dynamically create a sqlCacheDependency]? or both?

Normally I wouldn't reply if I don't understand the question - but
apparently nobody else is answering; perhaps they're confused as well. Maybe
it would help to break up this "master question" into individual other more
specific questions; one for the connection string, another for the dynamic
sqlCacheDependency. I'd take a shot at answering both here - but I don't
know the answers!

-GH

> I've got the standard SqlCacheDependency working just fine , ie. I've
> defined (and encrypted) the connectionStrings section in the web.config,
[quoted text clipped - 32 lines]
> missing
> something or it's harder than it should be.
Adrian Parker - 21 Oct 2005 00:19 GMT
Harry, thanks for responding..

Basically, the problem as we see it is that to use SQLCacheDependency, it
seems that you have to use a hard coded connection string in the cache
section of the web.config, which isn't going to work for us because we
cannot expose the specific database credentials to the network people who
would be specifying the DBserver and DBname to connect to; We can't have the
whole connection string in the web.config, and so have to build it in the
application at runtime e.g.

constr = "Data Source=" + aDBServer + ";Initial Catalog=" + aDBName + ";User
ID=" + aUser + ";pwd=" + aPwd

We know the user and password, but not the dbserver or dbname
and the customer network people know the dbserver and name, but not the user
or password.

So how do we use cache dependency without hard coding the connection string
in the web.config ?

Many Thanks
Adrian

> Maybe I'm just easily confused - but are you asking about [how to
> dynamically encrypt a dynamically created connection string], or how to
[quoted text clipped - 48 lines]
>> missing
>> something or it's harder than it should be.
Steven Cheng[MSFT] - 21 Oct 2005 06:17 GMT
Hi Adrian,

As for the connectionstring setting for ASP.NET 2.0's SqlDependecy caching,
it must be configured in web.config file and asp.net runtime will always
retrieve the configuration from there.  En, if you do need to dynamically
specify such connectionstring setting, we can consider using the .net 2.0's
configuration api to do it in applicatino_Start event, for example:

============
void Application_Start(Object sender, EventArgs e) {
       // Code that runs on application startup
       Configuration config =
           
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(HttpCo
ntext.Current.Request.ApplicationPath);
       ConfigurationSectionGroup group =
config.SectionGroups["system.web"];
config.ConnectionStrings.ConnectionStrings.Add(
           new ConnectionStringSettings( "aaa", "Data
Source=localhost;Initial Catalog=testdb;Integrated Security=True")
           );

       SystemWebCachingSectionGroup cachesg =
group.SectionGroups["caching"] as SystemWebCachingSectionGroup;
       cachesg.SqlCacheDependency.Databases["TestDB"].ConnectionStringName
= "aaa";

       config.Save();
}
================

actually the configuration api just provde the easy to use adminstation
interfaces for manipulating web.config(or app config....)

However, since it'll cause the web.config be modifed at runtime, we are
recommended to avoid using them in our application code as much as possible.

Thanks,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "Adrian Parker" <apparker@nospam.nospam>
| References: <O2VF#OZ1FHA.3568@TK2MSFTNGP15.phx.gbl>
<OOKvjya1FHA.4064@TK2MSFTNGP09.phx.gbl>
| Subject: Re: SqlCacheDependency - repost in hopes of a reply
| Date: Fri, 21 Oct 2005 00:19:54 +0100
[quoted text clipped - 7 lines]
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 82-37-128-226.cable.ubr01.telf.blueyonder.co.uk
82.37.128.226
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:132905
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
[quoted text clipped - 73 lines]
| >> missing
| >> something or it's harder than it should be.
Adrian Parker - 21 Oct 2005 07:56 GMT
Steven,

So in summary, because we cannot expose the database credientials to the
network people who would be specifying the dbserver/dbname, we cannot use
SqlCacheDependency as that requires you to compromise db security by
including the credentials in the web.config, which isn't possible when they
have to be specified at runtime.

If this is the case, then you really need to change this.

Thanks
Adrian Parker

> Hi Adrian,
>
[quoted text clipped - 160 lines]
> | >> missing
> | >> something or it's harder than it should be.
Steven Cheng[MSFT] - 24 Oct 2005 04:10 GMT
Thanks for your response Adrian,

Yes, as for your scenario, i'll be hard to utilize the current
configuration model of the sqlcache. However, because the sqlcache need to
be pre configured for each application(since the asp.net runtime need to
constantly do data polling from database), we need to specify the complete
server connection info at design-time rather than runtime. Anyway, i'll
forward this request to our dev team though I think it may takes time for
them to change the current sqlcache configuration model.
Thanks for your understanding.

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "Adrian Parker" <apparker@nospam.nospam>
| References: <O2VF#OZ1FHA.3568@TK2MSFTNGP15.phx.gbl>
<OOKvjya1FHA.4064@TK2MSFTNGP09.phx.gbl>
<epyPrzc1FHA.3124@TK2MSFTNGP12.phx.gbl>
<gx5cz6f1FHA.1144@TK2MSFTNGXA01.phx.gbl>
| Subject: Re: SqlCacheDependency - repost in hopes of a reply
| Date: Fri, 21 Oct 2005 07:56:50 +0100
[quoted text clipped - 7 lines]
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 82-37-128-226.cable.ubr01.telf.blueyonder.co.uk
82.37.128.226
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:132956
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
[quoted text clipped - 25 lines]
| >        // Code that runs on application startup
| >        Configuration config =

System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(HttpCo
| > ntext.Current.Request.ApplicationPath);
| >        ConfigurationSectionGroup group =
[quoted text clipped - 7 lines]
| > group.SectionGroups["caching"] as SystemWebCachingSectionGroup;
| >        
cachesg.SqlCacheDependency.Databases["TestDB"].ConnectionStringName
| > = "aaa";
| >
[quoted text clipped - 133 lines]
| > | >> missing
| > | >> something or it's harder than it should be.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.