Classic ASP – maintaining sessions between secure and non-secure pages

If you use secure (SSL) and non-secure pages on your IIS-powered web site, and are using session variables to hold information about your users, you most likely will find those session variable values disappearing as your user switches from non-secure to secure pages – for example, they are in your online shop, and then click to Checkout and Pay.

The problem is IIS – by default it creates a new sessionId for users when they hit the SSL pages – so any session values you already created against the non-secure page sessionId are lost.

It’s easy to fix, in IIS7 anyhow. In IIS go to the properties for your web site and open the ‘ASP’ properties page. There is an option down the bottom entitled ‘New ID on Secure Connection’. By default this is set to True. Change it to False and click the Apply link.

https_session

Switching between SSL and non-SSL can also be a reason users experience a time out, or seem to be automagically logged out in the middle of something.

Twitter API returns “There is no request token for this page”

Part of the fun of being a developer is keeping up with the advances, improvements and quirks in the APIs of the various online services you need to interact with. I spend a lot of time working with APIs from sites like Twitter, Facebook and SalesForce.

Late yesterday users on one of my sites started to report problems connecting their Twitter accounts, and posting to Twitter. The code on the site has been happily working for more than a year, so it felt to me something must have changed somewhere – and most likely at Twitter’s end. The error stated “There is no request token for this page”.

There is no request token for this paget 11.21.14 AM

I traced the issue to the initial OAUTH call to request a token, the first step to actually issuing a full request to the Twitter API. After a little research online I discovered someone else had experienced exactly the same issue. 

The solution is to specify a User-Agent in the POST, for example:

objXMLHTTP.SetRequestHeader "User-Agent", "something"

Note, this is exactly what I added – “something” seems to work fine. I’ve read that Twitter is continuing to tighten up access to their API, this issue only appeared yesterday for me, so clearly the Twitter devs have been tweaking things behind the scenes.

As a sidebar I was led up a small garden path for a short time. I tried pasting the request token URL directly into my browser and was rewarded with a message from Twitter “Failed to validate oauth signature and token”.

I played with this for a while before realising this error is almost always caused by the time clock on your server not being correct – remember, you are passing a time stamp as part of your URL, and Twitter checks that against its own internal time, if you are a little out of sync Twitter will reject the request. The time clock on my server is fine – and of course one then slaps ones forehead and realises that the time that elapsed between running your initial call, generating the URL, and pasting it into your browser is probably enough for Twitter to decide your time clock is wrong.

How to refresh Facebook’s cache of your blog post when you update

facebook

Came across this handy little trick the other day to refresh the Facebook cache of your web page or blog post. We all know that when you paste a link into the  status box on your Facebook page it goes away and grabs information from the URL, the title, summary and one or more images that you can then select to use as the thumbnail for your Facebook post.

But what happens if you update the blog post or web page? For example, I wrote a blog post, and pasted the URL into Facebook. Before I clicked the Post button I realised I had not added an image to the blog entry. So I went back and uploaded an image, then returned to Facebook and paste the URL again. Except Facebook didn’t show the new image.

The problem is Facebook caches the URL – so the second and subsequent time you paste the URL it is not retrieving a fresh copy, simply relying on the previously scraped information.

The quick way around this is to force Facebook to scrape the URL again. Go to the Facebook Debugger page,  paste in your URL and click the Debug button.

The Facebook Debugger page can be used to force a cache refresh.

The Facebook Debugger page can be used to force a cache refresh.

Then go back to your Facebook status update and paste the URL again there. Facebook should now display the latest version of the URL.

 

Paying the price of being a self-employed technology worker in Australia.

5792635506_697faa416d

As someone working in technology and living in Australia yet with a high degree of involvement with tech companies in the USA, I’m reminded of the massive cost differences every day between the two countries for geeks like me. So Peter Martin‘s article Soft Touches Pay the Price in today’s Age/Sydney Morning Herald simply just rubs even further a sore nerve with me.

Peter explains how companies use price discrimination to maximise profits. For example, supermarkets that manipulate the merchandising of vegetables to ensure the well-heeled pay a little more.

Price discrimination has been alive and well in technology and online, and as the technology improves, so does the discrimination become more pronounced. Amazon can display different prices for the same book depending not only on where you live, but your past purchase history. Regular buyers are charged more than new customers, presumably operating on the presumption that you’ve become comfortable with the idea of online buying and don’t require additional encouragement.

Terry Lane covered the technology price differences between Australia and the USA more than a year ago in his article Software prices defy comparison across borders. He offered up several examples of software that Australians pay more for than US residents. I know this pain first hand. Here are a couple of examples I checked today for software I use every day to earn my income:

Microsoft Visual Studio (it’s a key tool in a software developer’s armory): In the Microsoft US online store it costs $US499. In their Australian store the price is $A724. Given our exchange rate is almost at parity, and to keep the math simple, that’s a 45% premium – for exactly the same product, probably downloaded to my computer from the same Microsoft server.

Adobe Creative Suite monthly subscription: costs $US49.99 in the USA and $A62.99 to mugs like me in Australia. Not quite as eye-watering a difference as Microsoft but still a 26% premium.

What is particularly irksome about Microsoft is they deliberately penalise people ‘in the trade’, technology workers like me. Purchasers of consumer products such as the Windows operating system, and the Office suite, appear to pay the same – I compared prices and the $US and $A price tags were the same.

The cost of doing business as an Australian technologist is not confined solely to the software we use of course. Another key expense (for those of us working from home or our own small business office) is internet access. Whenever I chat with US tech friends about the cost of internet and telecommunications in Australia the conversation usually ends with them rolling around on the floor laughing silly. Because Australians pay through the nose for internet access.

I just checked the Comcast web site in the USA, one of the mainstream internet, phone and cable TV providers. I can buy a 30Mbs (=pretty darn fast) cable internet connection, plus a big bundle of TV channels, for $US49.95. Here in Melbourne, I’m paying Telstra $99 a month for my ADSL connection, and another $100 a month for my cable TV. Oh, and Telstra caps my downloads to 200Gb a month – Comcast does not appear to have any restriction. Americans historically, I believe, have not had ‘caps’ or usage limits on internet and phone plans, so again my US colleagues convulse when I explain how my son or daughter has racked up a big ‘over cap’ bill for exceeding their data allowance for the month.

All of this presumably feeds into the serious cost of living differences between the USA and Australia. I found this Cost of Living Comparison Between United States and Australia, and I compared Melbourne and San Francisco, which shows an astounding cost differential. For example, basic utilities (Electricity, Gas, Water, Garbage) are 90% more expensive in Melborne.

This is the last time I’m paying any attention to my geek friends in San Francisco moaning about how it’s such an expensive city. Because if they feel ripped off they ain’t tried paying the price of being a self-employed technology worker in Australia.

Image from Flickr artist in doing nothing