Asp.net sql cache dependency programmatically configuration - asp.net

I've a question regarding SqlCacheDependency configuration. Every resource I've read requires the developer to define the polled databases into web.config.
This is not a good scenario for our application that connects to different databases, because we don't want to edit web.config each time we add / remove a database.
We tried to configure it using SqlCacheDependency and SqlCacheDependencyAdmin in application startup but it seems that you must anyway configure everything in web.config.
Do you know a possible solution?
Thanks,
Marco

Related

What is the relationship between Oracle.Web and Oracle.DataAccess in-re Asp.Net Forms Auth?

I'm using oracle asp.net Forms Auth in my web app. The asp.net Membership/Role/Profile provider classes use Oracle.web.dll, and the connection string for these use Oracle.DataAccess.dll.
Now I want to change to Oracle.ManagedDataAccess.dll for the main application's data connection.
I made this change, and the app's main data connections work fine. However when any of the Forms Membership/Role/Profile methods are called, I get errors saying "Failed to load Oracle.DataAccess.dll".
I pointed the Forms Auth connections strings to a string using the Managed provider, but the Membership/Role/Profile parts seem to rely on Oracle.Web, which somehow looks for Oracle.DataAccess instead of the Oracle.ManagedDataAccess.
Can anyone shed light on this please?
Thanks,
--Jim
I ran into a similar problem and used Reflector to check references.
Yes, Oracle.Web.dll references Oracle.DataAccess.dll which further references OCI. Since OCI different for 64bit and 32bit one actually needs to install the appropriate Oracle client.
Hope that there will be a Oracle.Web version, that relies on Oracle.ManagedDataAcccess.dll soon.
The advantage of thru the use of oracle.manageddataaccess is kind of lost if one relies on profiles or membership providers.

WCF Cache vs. Page.Cache

I've got two different, but closely related ASP.Net web applications that use the same data on some pages. In both applications I am using the ObjectDataSource control, have EnableCaching="true", and use the same CacheKeyDependency value in both applications.
I would like to make it so that when a new record is inserted or deleted in one application, it clears the cache in both applications. I began by simply clearing cache by using Page.Cache, but soon realized that it does not clear the cache in the other application. Then I added a WCF service to each application; each service clears the cache object in the application it is hosted in. Except that it doesn't...
First, I discovered that System.Web.HttpContext is always null in WCF. Then I tried instantiating a System.Web.Routing.RequestContext object, but its HttpContext object is always null as well.
It all boils down to this: If I set a Page.Cache object, can a WCF service access that same cache object, if the service is hosted in the same application as the page?
Yes, you need to enable ASP.NET integration for the WCF service. This involves setting the aspNetCompatibilityEnabled attribute for the serviveHostingEnvironment element in config as well as adding the AspNetCompatibilityRequirementAttribute attribute to you service class to indicate that you support it.
More on this subject can be found here on MSDN.
The main challenge with cache in two applications is that the cache can be stored on seperate machines, or if they are on the same machine, in different application pools.
One way you can do this is to allow both applications to use the same cache. One solution for a distributed cache that runs out of process is Appfabric caching.

Find the tables in database being used for asp.net caching?

I suspect someone would have used database caching somewhere before in some other asp.net project. Further, I suspect a specific database would have been created for the caching needs too. My goal is to re-use what is already there: I need find the connection string to that database and let my asp.net application cache to the same database. Is there anyway I can find tables related to sql server object caching?
ASP.NET caches in memory not to database by default. It's only user sessions that can be configured to use the database. Any reason for wanting a database implementation of caching (database introduces performance overhead)?
Here's some info on writing an output cache provider in .NET 4.0.

Asp.net Membership and Roles Self Contained Web Application

I need to quickly wrap some security around an existing ASP.Net 2.0 web app. After thinking about it for a moment, I remembered that Microsoft created that Membership and Roles paradigm a couple of years back, and that Visual Studio could essentially create everything for you.
Thus I forged forward using the built in ASP.Net Web Site Administration Tool and created a simple little security framework around the application. After setting all of the options, Visual Studio created a nice little SQL Express DB called ASPNETDB.MDF right under the newly created App_Data directory of my website. This works great until you deploy it.
After trying to push this app to my DEV server I realized that it's not going to work unless you have SQL Express installed on the hosting machine. Worse yet, I figured that there's essentially no way this would work under a load balanced environment considering the DB itself will only be isolated to one of the N nodes.
Rather than work to script out the DB and shove it into my existing SQL box...I figured I'd ask the StackOverflow if there is a better solution for simple yet secure ASP.Net websites.
I'd love to maintain the existing model yet have the database become a local, or flat-file DB baked right into the application. For the time being I'm even fine with deploying the flat file with each user or role change to counteract the load balanced sites in PROD.
Is there not a way to create some sort of similar setup with a flat file? I thought that was the point of the App_Data folder?
You could use a custom Role & Membership provider that supports a flat file, like XML. Here is a link to a XML Membership provider, I've seen similar implementations for Roles.
XML Membership Provider
it's not going to work unless you have SQL Express installed on the hosting machine.
Not necessarily. If you still want to use default membership/role providers you can either have the DB server on the hosting machine or have one instance of the DB as a separate server (just change the connection string for providers).
Worse yet, I figured that there's essentially no way this would work under a load balanced environment considering the DB itself will only be isolated to one of the N nodes.
This statement is not really correct in this particular situation.
With load-balancing you will not have isolated database, but rather a separate database server.
I'd love to maintain the existing
model yet have the database become a local, or flat-file DB baked right
into the application. For the time
being I'm even fine with deploying the
flat file with each user or role
change to counteract the load balanced
sites in PROD
If you say that application with proper SQL DB will not scale, I do not understand how flat-file storage can.
You still can keep local SQL Server database and it will work as long as you take responsibility of maintaining the database consistency across different nodes.
In your situation, I would personally use default membership/roles provider as you do now.
But when deploying, just change the connection string to the proper database server.
You will need a database for other stuff anyway, so why not use the same database for all data withing the application (including membership/roles).
Regards.
I found an excellent solution to this here...http://aspnetxmlproviders.codeplex.com/. Using the dynamic XML you can hack out a simple provider based security model in no time flat.

Silverlight/.Net RIA Services - Authorization Working Sample?

I have followed numerous tutorials and walkthroughs/blogs about the capabilities that Ria Services brings to the table when using Silverlight with ASP.Net. Essentially I am looking for a live working example of the authorization functionality that Ria Services can apparently take hold of from ASP.Net. (Even better if it works with ASP.NET MVC too)
Example of failed to work Ria Services authorization implementation
Navigate to the live demo link on this page....fails
This one may work however I couldn't get it to work on my office computer(strange setup that seems to break code for no reason)
Check here: enter link description here. There is a bunch of posts giving samples. It not exactly what you want but has a walk-through for setting up full authorization.
Brad Abrams has some good information. Also note that the new "Silverlight Business Application" template in the Visual Studio -> New Project dialog has authentication set up already where you can mess around with it without having to figure out how to set it up first.
http://blogs.msdn.com/brada/archive/2009/10/05/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-part-26-authentication-and-personalization.aspx
C# Silverlight with RIA Services Authentication
Most likely you haven't configured your environment yet. In the machine.config file for the framework version in use, you will find LocalSqlServer defined. You should edit this definition to point at the SQL Server serving up the aspnetdb database that you want to use (and if you don't have one then start by setting up that).
Machine.config is generally in c:\windows\microsoft.net\framework\v2.something\config
For development you have to configure this in the workstation machine.config to make the debugger's webserver use your production authentication database. For production you have to do the same configuration on the production webserver.
There are different paths for 64 and 32 bit framework instances, and if like me you have 32 and 64 bit editions of version 2, 3, 3.5 and 4 then you have eight "root" configuration files. If you hunt them all down and set all of them it will save untold confusion later.
This is from my blog last october:
The Business Application Template for Silverlight comes with a login and register pages. It is very easy to connect these to a ASPNETDB.mdf.
Just add a LocalSqlServer connection string to your web.config file. For example, here is what I use to connect to Sql Server.
It’s almost too easy!
If you are using SqlExpress on your dev machine, it gets even easier. You don’t have to do anything. Just create a new Silverlight Business App and fire it up. Go to the log-on page and register. It will be slow, but in the background, your ASPNETDB was just created and attached, and you will be logged in. If you then look in the Web.config file, you won’t see a connection string anywhere, as the defaults are used for this piece of magic. Of course, a real world connection is going to need it’s own connection string like the above.
Greg

Resources