If you write cookie from ASP.Net code behind and try to delete from JavaScript client side, you may notice that even when you set the expire day to past, it is not actually deleting the cookie. The reason being cookie string used in JavaScript to delete it must match EXACTLY with the cookie string sent by ASP.NET to save it.
ASP.Net sends cookie as
login=myloginvalue; expires=gmtdate; path=/
So if you have to delete it, You have to write the following JavaScript to delete the cookie:
var expires = new Date();
expires.setUTCFullYear(expires.getUTCFullYear() - 1);
document.cookie = 'login=; expires=' + expires.toUTCString() + '; path=/';
This works with both IE and Firefox. Thanks to Henri to post this solution :)
Wednesday, December 17, 2008
Monday, December 15, 2008
Unit test your JavaScript
JsUnit (http://www.jsunit.net/) is a great tool for unit testing your JavaScript code. Te best part is that it can be integrated with build process for continuos integration. This helps to identify the errors at a early stage of development rather than waiting till the code has reached QA.
QUnit (http://docs.jquery.com/QUnit) is another unit testing from jQuery stable. All jQuery libraries are tested using qUnit. I have not yet included this as part of build but as per their documentation it can be integrated into browser automation tools like Selenium or Mercury.
QUnit (http://docs.jquery.com/QUnit) is another unit testing from jQuery stable. All jQuery libraries are tested using qUnit. I have not yet included this as part of build but as per their documentation it can be integrated into browser automation tools like Selenium or Mercury.
Friday, November 28, 2008
Move ahead XML and JSON - Here comes BISON
In case you have a webservice/AJAX application which relies on sharing big chunk of data and you want to improve the communication time, one option is to reduce the payload. We generally used to use JSON rather than XML for this. As part of our new development we figured out that even JSON can be too much for us. Then there comes BISON (Binary Interchange Standard and Object Notation). I would suggest you to have a look at it :)
http://www.kaijaeger.com/articles/introducing-bison-binary-interchange-standard.html
http://www.kaijaeger.com/articles/introducing-bison-binary-interchange-standard.html
Friday, October 31, 2008
Analyzing IIS log files
AWStats is an open source free tool that can be used to analyze IIS log files. It can be downloaded from http://awstats.sourceforge.net/
Setup
- Perl is a prerequisite for AWStats. A version of this can be downloaded from http://www.activestate.com/Products/activeperl/index.mhtml. This tool also adds perl command to PATH environment variable
- Download AWStats from http://awstats.sourceforge.net/#DOWNLOAD
- Install AWStats to your hard disk (say D:\Program Files\AWStats)
- Create a folder for AWStats on your hard disk. It will be used as web deployment folder for AWStats (say C:\Inetpub\wwwroot\awstats)
- Copy D:\Program Files\AWStats\wwwroot\*.* to C:\Inetpub\wwwroot\awstats\
- Make a copy of C:\Inetpub\wwwroot\awstats\cgi-bin\awstats.model.conf and name it as C:\Inetpub\wwwroot\awstats\cgi-bin\awstats.mysite.conf where mysite is domain of the website (it can be anything though)
- Edit awstats.mysite.conf and set following properties
- LogFile="D:\Production Log\39\ex081030.log" (path to log file being analyzed)
- LogFormat="date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken" (This format can be copied from IIS log file. Open log file in text editor and copy from this line at top #Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken
- SiteDomain=www.mysite.com
- There are other properties which can be customized. Refer to doc in D:\Program Files\AWStats\docs
- On command prompt enter following commands
perl awstats.pl -config=mysite -update
perl awstats.pl -config=mysite -output -staticlinks > awstats.mysite.html
perl awstats.pl -config=mysite -output=alldomains -staticlinks > awstats.mysite.alldomains.html
perl awstats.pl -config=mysite -output=allhosts -staticlinks > awstats.mysite.allhosts.html
perl awstats.pl -config=mysite -output=lasthosts -staticlinks > awstats.mysite.lasthosts.html
perl awstats.pl -config=mysite -output=unknownip -staticlinks > awstats.mysite.unknownip.html
perl awstats.pl -config=mysite -output=alllogins -staticlinks > awstats.mysite.alllogins.html
perl awstats.pl -config=mysite -output=lastlogins -staticlinks > awstats.mysite.lastlogins.html
perl awstats.pl -config=mysite -output=allrobots -staticlinks > awstats.mysite.allrobots.html
perl awstats.pl -config=mysite -output=lastrobots -staticlinks > awstats.mysite.lastrobots.html
perl awstats.pl -config=mysite -output=urldetail -staticlinks > awstats.mysite.urldetail.html
perl awstats.pl -config=mysite -output=urlentry -staticlinks > awstats.mysite.urlentry.html
perl awstats.pl -config=mysite -output=urlexit -staticlinks > awstats.mysite.urlexit.html
perl awstats.pl -config=mysite -output=browserdetail -staticlinks > awstats.mysite.browserdetail.html
perl awstats.pl -config=mysite -output=osdetail -staticlinks > awstats.mysite.osdetail.html
perl awstats.pl -config=mysite -output=unknownbrowser -staticlinks > awstats.mysite.unknownbrowser.html
perl awstats.pl -config=mysite -output=unknownos -staticlinks > awstats.mysite.unknownos.html
perl awstats.pl -config=mysite -output=refererse -staticlinks > awstats.mysite.refererse.html
perl awstats.pl -config=mysite -output=refererpages -staticlinks > awstats.mysite.refererpages.html
perl awstats.pl -config=mysite -output=keyphrases -staticlinks > awstats.mysite.keyphrases.html
perl awstats.pl -config=mysite -output=keywords -staticlinks > awstats.mysite.keywords.html
perl awstats.pl -config=mysite -output=errors404 -staticlinks > awstats.mysite.errors404.html
I prefer to create a batch file with all these commands and pass site name as parameter.
Once executed, it will create multiple .html files in C:\Inetpub\wwwroot\awstats\cgi-bin (provided you have not configured any other path in awstats.mysite.conf). Open http://localhost/.../awstats.mysite.html (depends on where you created web deployment folder) which is the index page and you are done.
Hope this helps when you have to analyze log files next time :)
Tuesday, October 07, 2008
LIVE Data Update (.Net)
What if you want to update data on webpage real time? The exisitng option is "PULL" where client polls server for updates and when retrieved it updates data on page. This works but issues
But the scenario is changing. HTML 5 is coming up with Web-Sockets and Server-Sent Events (http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html).
But what if you want to implement PUSH implementation now?
Well. you have couple of options:
1. COMET - Works but is not scalable as it relies on keeping a thread open on the server till client closes the connection. Not feasible for high volume websites.
2. http://www.themidnightcoders.com/weborb/dotnet/
3. http://www.lightstreamer.com/
Hope this helps you in your next project :)
- There is a lag between data update and data refresh and this depends on delay between each refresh call.
- Unnecessary load on server and network even though there is no data update.
But the scenario is changing. HTML 5 is coming up with Web-Sockets and Server-Sent Events (http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html).
But what if you want to implement PUSH implementation now?
Well. you have couple of options:
1. COMET - Works but is not scalable as it relies on keeping a thread open on the server till client closes the connection. Not feasible for high volume websites.
2. http://www.themidnightcoders.com/weborb/dotnet/
3. http://www.lightstreamer.com/
Hope this helps you in your next project :)
Thursday, October 02, 2008
Which cell to buy....
Well finally i made up my mind to say bye-bye to my old Nokia 6030 and go for a Biz Class cell phone (a big leap of faith for me). Many a times I really think - do I need a big phone and then my brain says - comeon, you need to show off man ;)
But the problem was not to make up my mind. Problem is to select a phone. There are so many choices that uffffffffff, which one to go for.
The other problem is upcoming cellphones. they are hyped so much that i am not sure if i should wait for their launch or not.
Someone has said true - "Mobile and wife, if u wait for sometime you could get a better model ;)"
Anyway my confusion is between these:
Blackberry Bold
HTC Diamond
Samsung Omnia
Apple IPod 3G
Upcoming models
HTC Google Android Based
Blackberry Thunder
Well if someone can suggest something on this subject, I am eager to listen. But please do not suggest any other model. I am somehow leaning towards Omnia as Blacberry is too business and iphone has too many limitations. But someone said about Omnia, hey that is Samsung :)
But the problem was not to make up my mind. Problem is to select a phone. There are so many choices that uffffffffff, which one to go for.
The other problem is upcoming cellphones. they are hyped so much that i am not sure if i should wait for their launch or not.
Someone has said true - "Mobile and wife, if u wait for sometime you could get a better model ;)"
Anyway my confusion is between these:
Blackberry Bold
HTC Diamond
Samsung Omnia
Apple IPod 3G
Upcoming models
HTC Google Android Based
Blackberry Thunder
Well if someone can suggest something on this subject, I am eager to listen. But please do not suggest any other model. I am somehow leaning towards Omnia as Blacberry is too business and iphone has too many limitations. But someone said about Omnia, hey that is Samsung :)
Thursday, September 04, 2008
All softwares crash one day...
... and so does Google Chrome. In an article on the Securiteam site, Rishi Narang from Evilfingers says a crash can occur without user interaction. If a user is provided a malicious link with an undefined handler followed by a special character, Chrome crashes...
You can read more details at http://evilfingers.com/advisory/google_chrome_poc.php. There is a demo link on the page. If you click on it, chrome crashes (and with all tabs).
You can read more details at http://evilfingers.com/advisory/google_chrome_poc.php. There is a demo link on the page. If you click on it, chrome crashes (and with all tabs).
Tuesday, September 02, 2008
Google Chrome is out...
Finally the browser we all were waiting for is out. Google Chrome is available for download at http://www.google.com/chrome. The features are highlighted here http://www.google.com/chrome/intl/en-GB/features.html and the complete story is here http://www.google.com/googlebooks/chrome/. But while you are at it, don't forget to get your hands on IE8 beta 2 http://www.microsoft.com/windows/internet-explorer/beta/.
Saturday, August 23, 2008
iPhone 3G is OUT...
... BUT is it worth it's hype? Priced at >30K is it really worth? The touch and feel feature is very nice but that's because it's a new concept (not anymore though). But an enterprise user needs more than that. Some cool feature missing from the new 3G are:
And if you awant to show off and flaunt it, go ahead ;)...(Remeber the ad... Nice phone...)
- It has no video recording option iPhone will disappoint you here.. This is quite surprising since video recording feature is today found in most cell phones, even those at the lower end.
- It has 2 mega pixel (MP) cameras. Flash and optical zoom are missing too. Despite a 2 mega pixel camera -- belie that number and turn out quite clear.
- One cannot simply forward a text message. Users can only send text messages or snapshots via email. Also, don't think of sending a SMS to multiple contacts as iPhone has no option for that either.
- Lack of multimedia messaging controls and voice dialing. It lacks support for voice-recognition to let users dial verbally
- No cut, copy-and-paste. Imagine you cannot even select a line of text to delete it. And how bad can it be living without copy and paste option. Especially when you want to post a URL in your blog! How tedious it would be to jot it down, word by painful word.
- It lacks support for multi-select. It will give users a tough time deleting every email one by one as they cannot delete mails in bulk. Same goes for photo albums. Users have to delete the same too one by one
- All you heavy phone users, you cannot change an iPhone battery. You will have to send it to an Apple outlet for this. Imagine how troublesome it would be to live without your phone for 2-3 days. And that is an optimistic estimate of the time that you may spend twiddling your thumbs!
- iPhone offers no support for wireless modem. You may pay heavy data charges to activate Internet on your iPhone, but you cannot connect it to your PC and browse when you are at home.
- iPhone can't sync with Bluetooth stereo or in-car Bluetooth hands free. It lacks A2DP on Bluetooth. A2DP audio devices, such as stereo Bluetooth headsets, offer high quality listening ability.
- you cannot share MP3, images and video files via Bluetooth, half the fun is gone.
- In case you wish to see those multimedia files that require Flash, you will have to do away with them. There is no support for Adobe Flash in 3G iPhone. Though, Adobe says it is working on iPhone Flash.
- iPhone offers You Tube support. But how? Here's a catch. Users cannot get all You Tube video, but only a few selected ones that have been rolled out for the Apple-favored H.264 video codec. So, this means you can't go on sharing your videos.
- please do remember, unlike the true Push platform enjoyed by Blackberry, the iPhone email client does not work in true Push fashion, but is more of a "pull" mail.
- Last, but not the least, be aware that as a customer you are unlikely to get much support from the operators in setting up your haloed iPhone. And since setting it up would be essential to use a number of features.
- Sending out the cool pics you shoot through iPhone's excellent 2 mega pixel camera will be a challenge unless you have set up the email accounts.
And if you awant to show off and flaunt it, go ahead ;)...(Remeber the ad... Nice phone...)
Thursday, June 26, 2008
JavaScript | Print all properties of Object
To Print all properties of an object in JavaScript, use for-in as follows:
<script language="Javascript">
var obj = new Object(); //Create new object
obj["firstName"]="Davendra"; //Assign property firstName with value Davendra
obj["lastName"]="Upreti"; //Assign property lastName with value Upreti
var str=""; //variable which will hold property values
for(prop in obj)
{
str+=prop + " value :"+ obj[prop]+"\n"; //Concate prop and its value from object
}
alert(str); //Show all properties and its value
</script>
Monday, May 12, 2008
Multiple websites on XP
XP Pro IIS Admin is a free tool for using on Windows 2000/XP Pro. It allows you to create multiple websites and easily switch between those websites. Without this utility on Windows 2000/XP Professional, only one website can be created.
You can get it here: http://jetstat.com/iisadmin/
You can get it here: http://jetstat.com/iisadmin/
Wednesday, April 30, 2008
Not able to map Network Drive? Read on..
Ever got this problem while mapping a network drive:
The network folder specified is currently mapped using a different user name and password.To connect using a different user name and password, first disconnect any existing mappings to this network share.
And when you see your network mappings, strangely the drive is not mapped :(
Well, the solution is old reliable DOS commands. here it goes:
> net use
> net use \\SharedDrive /delete
net use command displays a list of all mapped drive. there will be a IPC$ mapping for the drive you want to connect to. Just delete the sharing and then you will be able to connect to the server.
FYI: The Inter-Process Communication (IPC) share or ipc$ is a network share on computers running Microsoft Windows. This share is used to facilitate communication between processes and computers, often to exchange authentication data between computers.
The network folder specified is currently mapped using a different user name and password.To connect using a different user name and password, first disconnect any existing mappings to this network share.
And when you see your network mappings, strangely the drive is not mapped :(
Well, the solution is old reliable DOS commands. here it goes:
> net use
> net use \\SharedDrive /delete
net use command displays a list of all mapped drive. there will be a IPC$ mapping for the drive you want to connect to. Just delete the sharing and then you will be able to connect to the server.
FYI: The Inter-Process Communication (IPC) share or ipc$ is a network share on computers running Microsoft Windows. This share is used to facilitate communication between processes and computers, often to exchange authentication data between computers.
Subscribe to:
Posts (Atom)