ASP - Get vs Post
Most of the common form method handling will not escape the usage of GET or POST method to submit the data. While working on a project and experimenting both the methods I found out an interesting result...
GET got priority over POST method. If you use the Request.Querystring method in ASP, it will obtain all the required parameters. But for the POST method, doing a Request.Form method will not necessary obtain all the values. It seems that there is some kind of priority on the values obtain.
This lead me to wonder if anyone knows the sequence of which overwrites the priority first? I know that in php, the php.ini file allows you to edit the global, get, post objects and method, and that you could set the priority of the objects to be used first and overwritten priority. Thus I wonder if there is any for ASP Request.Form & Request.Querystring objects?
25+ ASP Tips to Improve Performance and Style
Found a good link from Microsoft on tips to improve performance and style for ASP!
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnasp/html/asptips.asp
Base64 Encoding Fun
And now for some encoding fun :P
The most common encoding that I like to use is Base64 Encode. Over the past 1 years plus, this encoding have proved to be very useful and I shall some tricks and tips that I discover! For fun with online base64 encode or decode check this site out.
1) Base64 encoding and decoding is dependent on the language charset that you set in. For example if you are encoding in a page with iso-8859-1 and a utf-8, the result encoding is different. I believed this is due to the different byte used and the character set used in the encoding.
2) Base64 encoding is useful to hide away clear text message.
3) My most important topic here! Base64 encoding can used in email subject and content. While working with mult-lingual email. the challenge is always to get the correct character displayed with showing gibberish stuffs. For my experiments before, I found out that base64 encode subject line are more reliable than quote-text for double-byte language email.
Due to the various different sytems operating in their settings and configuration, when a double-byte mail subject is quote-text, the result maybe displayed incorrectly. On some machine, it might displayed as you wanted, but not for some especially for those web-based email viewed online!
To send out double-byte character email ,the provided CDONTS and CDOSYS system on Microsoft Windows platform needs you to set the correct Session Codepage and encode the mail subject using quote-texted. When checked the reference, both the CDONTS and CDOSYS does not allow the mail subject to be base64 encoded! So for those mail subject that I received and does not appear correctly, how do we tackle this problem? One way you can do is change the subject liner to some other content. But what if the client insisted on it?
My solution that I discovered that it worked.- With the double byte mail subject, go to the online base64 encoding/decoding site link.
- Set the page to the correct charset, ie: for Simplified Chinese, set the charset encoding to "gb2312"
- Paste the subject string into the text box and encode it.
- Copy the encoded string from the site.
- In your server script, (I am using asp with CDONTS as example below), set the mail subject line to the use the base64 encoded text with defined encoding used.
ie: =?gb2312?b?xxxxxSubject-base64xxxxx==?=
Example with ASP using CDONTS
<%
'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
With objCDOSYSMail
.From = strEmail
.To = strFriendEmail
.Subject = "=?gb2312?b?" & strSubject & "==?="
End With ' objCDOSYSMail
%>
- Send out the email in the script, and when you receive your email, you see that the subject is displayed in the correct encoding! The above mail subject is set to follow the rfc mail header standard and it seems that once you specify the encoding there, it will overwrite the quote-text encoding in there!
Javascript Error - submit
A few days back while doing a javascript form submit status, I encountered the weird error in my javascript-ing life. The problem is with the statement below:
document.form.submit();
Yes, it look very much like a normal javascript form submit statement. However, on the Mozilla Firefox javascript console, it is throwing back in my face the error message "Object doesn't support this property or method"!
After desperate testing here and there, I search and google around for an answer and found out that I have make a stupid mistake. The problem was caused by having a submit button that has the name "submit", ie:
<input type="submit" name="submit" value="Submit">
As the form submit is a reserved method, any button name or input name that is named "submit" shall encounter this problem. So folks, take note not to name any input object "submit". The error vanished when I renamed the button to "Submit", ie:
<input type="submit" name="Submit" value="Submit">
Thanks to helpful information on the net, especially from this site here: http://www.agape-love.net/?item=document-form-submit-doesn-t-work&catid=13
Stupid Javascript :P
Self-Signed IIS SSL Certificates
While looking around on how to do use self-signed IIS SSL certificate using OpenSSL, I came across the below article content from the author Eric Longman on his site. Thanks for the useful contribution! Other than using a Linux system, windows user can look to using CYGWIN installed with OpenSSL which also does the same work!
=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=
Self-Signed IIS SSL Certificates using OpenSSL
This tutorial assumes that you have a Linux box with OpenSSL installed,and that you want to create a self-signed certificate for IIS5.0
- Set up your CA (you only have to do this once)
ON THE LINUX BOX... - Create a private key
openssl genrsa -des3 -out CA.key 1024
(You'll need to supply a passphrase. DON'T FORGET THIS!!)
- Set this to read-only for root for security
chmod 400 CA.key
- Create the CA certificate
openssl req -new -key CA.key -x509 -days 1095 -out CA.crt
(Provide appropriate responses to the prompts...for Common Name, you might want to use something like "OurCompany CA")
- Set the certificate to read-only for root for security
chmod 400 CA.crt
- Obtain a CSR
ON THE IIS BOX... - Open the Internet Manager
- Select the site for which you want to create a key
- Right-click and choose Properties
- Select the "Directory Security" tab
- Click the "Server Certificate" button
- Follow the prompts to create a CSR
- Save your CSR, then transfer it to the Linux box for further processing. (For the following steps, we'll refer to your CSR as "new.csr")
- Sign the CSR
ON THE LINUX BOX... - Sign the CSR (all of this on one line)
openssl x509 -req -days 365 -in new.csr -CA CA.crt
-CAkey CA.key -CAcreateserial -out new.crt
- Transfer the new.crt file back to the IIS box
- Install self-signed certificate
ON THE IIS BOX... - Open the Internet Manager
- Select the site to install the key
- Right-click and choose properties
- Select the "Directory Security" tab
- Click the "Server Certificate" button
- Specify that you want to complete the pending request
- Select the .crt file that you just transferred
Original content from Eric Longman - http://eal.us/blog/_archives/2003/6/2/25109.html
=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=