Visual Basic / ASMX - how to use application cache variable? - vb.net

I'm trying to amend our content management system so it'll handle SQL database failures more gracefully. It's a bunch of ASMX pages, and a Helpers.vb file in which I've written a SQL connection tester function.
Each of the ASMX pages call the same function.
I need to create a variable I can check that's persistent and performant, otherwise I'm going to have fall back on something disasterously slow like reading a text file every time I set up a sql connection string.
I've tried using application caching, but either it doesn't work in the context of my helpers.vb file, or I've made a mess of the syntax. One problem that's already stymied some of the approaches I've found via google - I can't use 'Import System.Web.Caching' - IntelliSense doesn't show the 'Caching' part.
Has anyone got any example code that might get me up and running? Or an alternative approach?

#Mike,
Many thanks, now I'm using HttpRuntime.Cache correctly... it works!
Thanks everyone for taking the time to post :)

Related

Possibilities of Datazen server migration

I know that similar topics have been already raised, but maybe there are some latest news or ideas?
I want to migrate Datazen users/sources/dashboards etc. to another server (production one) in a smooth way. I was trying to do that via backup/restore, but then I couldn't access the control panel on the target server. I received an error
401 unauthorized access.
Maybe I should change something in logs/config files on the destination server?
Any ideas? I would be grateful for any help!
I dont think there is a way to do this out of the box. However, the files are quite simple XML, so can be pointed at a different server if you know PowerShell (and work out the correct values from the server).
You will have to re-point the GUID, ServerGUID and ServerURI within the sources.xml file and then rezip (as .datazen). Providing you have your hubs set up the same, Datazen will then believe the file belongs to your prod environment and you will be able to publish

Alternatives to traditional database topology

I've been working with visual studio in a corporate environment for a long time, where we have a central SQL Server set up to store the data for all our in-house programs.
I've been asked to work on a side job for a small company where they want a program that will share data from a database between a half dozen computers.
My first reflex is to get them to set up a small server, install a database and then connect to it like I usually do, but before I start I'm wondering if there is a better way to do it.
Part of my problem is that if this works out really well, there is a chance that the program could be used in other companies, and I don't want to have to set up a server and write a custom version with a custom connection string for each one.
It could be that I'm thinking to deeply about this, I'm just hoping that a little research ahead of time might save a lot of time down the road.
Why would you need a custom build just to change the connection string ?
Just change your app App.config - or are we missing something here ?
What is App.config in C#.NET? How to use it?

Query RavenDB without using the studio interface

I am trying to view my sagas in the RavenDB management studio, and loading even the initial page, all that I see is this "Querying documents..." box with a continuous moving progress bar. I can not seem to get past it, going from page to page it does not go away. Is there a way to pull all of the saga data into a list so I can look at it? It appears the issue is that the saga documents are continuously being added.
I've looked into the HTTP API and the Linq adapters, but I guess I am looking for something that already exists that can easily peer into the server much like the silverlight studio, except not such a pain. I more or less just want to pull a snapshot of all the documents into some kind of readable list.
I find LINQPad 4 convenient, the RavenDB driver for LINQPad can be found here:
https://github.com/ronnieoverby/RavenDB-Linqpad-Driver
For the command line - cURL using dynamic indexes as explained here:
http://ravendb.net/docs/http-api/indexes/dynamic-indexes
In the browser, go to http://localhost:8080/docs
You might need to install JsonView, but that should give you what you want.
If anyone wants to know how to browse the data through REST call,
"localhost:8080/databases/{database-name}/docs/{dataset-name}/id"
example:
"localhost:8080/databases/testDB/docs/Sites/1"
will give the json data for the "Sites" document
"localhost:8080/databases/testDB/docs/"
will give the json data for all the documents in
testDB.

Small SQL Database for logs?

Im thinking about to use a DB for my logs instead of a normal txt file. Why? In a DB I could handle them much more easier than with a txt file. Actually I dont have a big log txt, there are some exceptions, and for every single day: userlogins and what client uploaded what file where - but even here, a DB would make sense or? What free (for noncommercial and for commercial) small DBs should I try? I could use a "real" DB like PostgreSQL or nosql with a simple XML DB with BaseX, so that's what I thought. Any suggestions? Thank you.
Edit: Oh sry forgot - Im using .NET, but maybe that's not so importan.
What will you do with your logging information? If you are going to do regular complex analysis work on it (performance, trending, etc.) then a database would be very useful. If you just need a place to dump "this happened" type messages that will be used infrequently at best (post-crash analysis and the like), a simple text or XML file should be more than sufficient. (If you do that, cycle the files ever day or week -- rename the current file, say with the date/time, and start a new "current" log file.)
Use SQLite. Really small footprint, cross-platform, single file for the whole db and serverless (http://www.sqlite.org) Give it a try.
Using the Package Manager you can install SqlServerCompact which works within your solution.
Use the Package Manager Console and type the following command:
Install-Package SqlServerCompact

Is it possible to detect ASP Session State Type from code?

I'm trying to track down a problem on our test environment. Previously it was set to use InProc Session State Type, but I've added in the SQLServer type for one specific Web App. I did this because we use the SQLServer type in our production environment and I want our test env to match as closely as possible.
However, after changing it to SQLServer I do not get any errors when trying to store unserializable data in session like I would expect. It works just fine, even though I would think it shouldn't. I'm a relative newbie when it comes to configuring this, but from the various tutorials I googled, I thought I covered all the bases.
I was wondering if there's any code snippets to verify which session state type an application is actively using.
Thanks
Ok, found it by accessing:
System.Web.SessionState.HttpSessionState.Mode
Was also able to look at the tables in the ASPState database to see sessions being added/removed.
Apparently it was just the test code we were using that we expected to break that was not behaving as we expected..