ASP.NET - How to add some number crunching code behind the scenes

Asked By chaz d'chaz on 10-Sep-13 10:49 PM
Greetings Nullskulls (more on that later):

I'm a newbie to asp.net. If fact, i'm experimenting on my own (yet to be published) page. My background is vba and c++., just so you know.

The page will retrieve data from a third party site, and then crunch the numbers and display the results on my page.

My view on all this is through VS 2005 -- so, I know I can add class modules add infinitum and use VB.Net to do my math.  How exactly to get it function in happy harmony with the proposed webpage display is the question.  How to get it uploaded to a host server will be a future question.

For the data-getting part, I've decided to stick with a  trusty excel object called "Web Query". I admit I know little about the HTML and IE explorer libraries, but I've tried them, and seem really difficult to work with. The Web Query is tested, it works -- the third party site is very weird and this seems like the easiest way to get the data in question.  So why not cut myself a break and use it?

That done, I'll dump the data it into a little Access db and parse as necessary, do my math, and then put the results into a gridview.  To manipulate Access, I presume I'll use something along the lines of the ADO stuff that's served me so well in VBA, but I'll probably find that .NET won't let me --  I'll cross that bridge when I get to it.  As for the griview,  I've tested one, and have got a primitive one wired together. 

It seems efficient and ecologically commendable, if it's possible, to create my webquery once, and then refresh it every time the page is loaded (I'll bet I don't get one hit a day).  But this is where things get mysterious for me.  If I follow this path, I don't want to the web query to be created each time the page is loaded, only once.  I thought I'd have the existence of the object tested each time the page is loaded, and refreshed if it exists, or created if it doesn't.  It would be easy enough in a stand-alone procedure, but when servers and things are involved, I get a little dizzy.  What I have so far works fine in "debug", but gawd only knows what's going to happen when it's requested multiple times from a server.

All this to set up the first question:  I am under the impression that a "Shared" member of a class is not instantiated each time the class is.  If so, I would make the Web Query a "shared" member and thus  it would only be created on the first page load (ie the class instantiated on a "page load" event), and lying in wait to be refreshed on any future pageloads.  Is my understanding of a "shared" member of a class correct?  There's probably a better way to accomplish this, right?

Of course, thank you in advance.
Robbe Morris replied to chaz d'chaz on 11-Sep-13 07:48 AM
Neither Microsoft Access or Microsoft Excel are suited for multi-user environments like the web.  Both are prone to locking up the IIS process they run under via your web site.

We are up to Visual Studio 2012.  That means, Visual Studio 2008 and 2010 are still newer than what you are using.  I would suggest various code samples for getting the contents of your third party site but they'd all be classes, methods, and properties not available in Visual Studio 2005 and .NET 2.0.

Yes, I believe VB.NET's shared is the same thing as static in C#.  It is best used when its read only once populated.

This will help you with ado.net:

https://www.nullskull.com/articles/20030729.asp