Sunday, October 23, 2011

ASP.NET MVC Pipeline

Life cycle of a request in ASP.NET MVC.


Sunday, October 16, 2011

SQL to get unique entry and the date it was first entered

Let's say you have this table:

Email          EnteredDate
abc@abc.com    11/1/2011
xyz@zyx.com    11/1/2011
abc@abc.com    11/2/2011

and you want to get list of unique emails and the date when it was first entered. Then this query:

SELECT email, min(EnteredDate) as FirstEntered FROM entries
GROUP BY email

will give you this result displaying unique email with the date it was first entered:

Email          FirstEntered
abc@abc.com    11/1/2011
xyz@zyx.com    11/1/2011

If you know any better solution then please share it with me.

Tuesday, October 11, 2011

Tool to debug Facebook's Open Graph protocol


Great tool to debug Facebook's Open Graph protocol https://developers.facebook.com/tools/debug

This tool displays all Open Graph Object properties which helps us to debug the properties we have set on our pages. This way we will be sure whether we have set the properties correctly or not.

Monday, October 10, 2011

Fix for facebook iframe scrollbar issue

Sometimes FB.Canvas.setAutoResize or FB.Canvas.setSize fails to remove the scrollbar from applications. To fix it you can put <body style="overflow:hidden"> in body tag.

Saturday, October 8, 2011

Tuesday, October 4, 2011

CFHTTP issue with Connection Failure: Status code unavailable


I was trying to connect to client's remote URL using CFHTTP and I was getting an error saying "Connection Failure: Status code unavailable". So to fix that I used below code and this solved by problem:

<cfobject action="Create" name="objSrvHTTP" class="MSXML2.ServerXMLHTTP">
<cfset temp = objSrvHTTP.open("GET","http://google.com")>
<cfset temp = objSrvHTTP.send("")>
<cfset myResult = objSrvHTTP.responsetext>

Show custom page for run-time exceptions occurred in servlet


In Coldfusion if you see errors in servlet with a stack trace like below:



then in order to get custom error page you need to add this code


<error-page>
<error-code>500</error-code>
<location>/500.cfm</location>
</error-page>


in default-web.xml. You can find this xml in this location C:\JRun4\servers\cfusion\SERVER-INF\.

Ref: http://livedocs.adobe.com/jrun/4/Programmers_Guide/techniques_servlet12.htm

I created the above error by capturing the form post using Live HTTP Headers add on of Firefox and changing the content length and replayed the request. When I do this then cferror was not capturing that error. So had to do this way in order to show custom error.