Wednesday, April 8, 2009
A Start In Joomla
I've been trying out Joomla, the free and open-source CMS developed in PHP. I set it up on XAMPP and the first thing I can tell is that it's not very intuitive. The features provided on Joomla make it worth the effort to learn it all though - advertising banner management, contact lists, news feeds, polls, search and more.
Twitter Hands Over Registration Details of "Skype"
Twitter handed over the registration details of the user "Skype" to Skype Inc. It definitely raises privacy concerns, but what makes this extreme is that they do not notify the user when they do reveal private data.
Monday, April 6, 2009
Manual Sliding Expiration
When using ASP.NET Forms Authentication, ASP.NET sets a timeout of 30 minutes by default for which a user is logged in. If the user does make a request within the 30 minutes, the authentication ticket is renewed for a another period. This normally happens behind the scenes and the developer is often not aware of this process, known as sliding expiration.
However, if you've got some pages on your web application that should be viewable by the user without the authentication ticket being renewed (such as a ticker to display new messages within an IFrame), you can disable slidingExpiration by making the following change in the web.config file:
You then have to programatically perform sliding expiration within your code, which can be done with the following code snippet posted at:
http://forums.asp.net/p/1083581/1607975.aspx
In the code snippet above, you would have to change the condition within the IF statement that checks Request.Url to exclude the pages for which you do not want slidingExpiration to occur. The example above excludes all requests to ASP.NET Generic Handlers (files ending in .ashx).
However, if you've got some pages on your web application that should be viewable by the user without the authentication ticket being renewed (such as a ticker to display new messages within an IFrame), you can disable slidingExpiration by making the following change in the web.config file:
<authentication mode="Forms">
<forms slidingExpiration="false"></forms>
</authentication>
You then have to programatically perform sliding expiration within your code, which can be done with the following code snippet posted at:
http://forums.asp.net/p/1083581/1607975.aspx
// Acquire Auth Ticket from the FormsIdentity object
FormsAuthenticationTicket objOrigTicket = ((FormsIdentity)Context.User.Identity).Ticket;
if (!Request.Url.AbsolutePath.ToLower().EndsWith(".ashx"))
{
// Manually slide the expiration
FormsAuthenticationTicket objNewTicket = FormsAuthentication.RenewTicketIfOld(objOrigTicket);
if (objNewTicket.Expiration > objOrigTicket.Expiration)
{
// Create the (encrypted) cookie.
HttpCookie objCookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(objNewTicket));
// Add the cookie to the list for outbound response.
Response.Cookies.Add(objCookie);
// Update original
objOrigTicket = objNewTicket;
}
}
In the code snippet above, you would have to change the condition within the IF statement that checks Request.Url to exclude the pages for which you do not want slidingExpiration to occur. The example above excludes all requests to ASP.NET Generic Handlers (files ending in .ashx).
Sunday, April 5, 2009
Aspose Library for Creating Excel and Word Files

If you want to generate Excel and Word files using .NET or Java code, then the Aspose.Cells and Aspose.Words libraries are just what you are looking for. The Aspose.Cells library costs roughly $600 while the Aspose.Words library costs about $900, but you can get a discount of about $200 for purchasing both libraries in a single transaction. You might want to buy Aspose.Total, which is a package containing both Aspose.Cells and Aspose.Words along with several other useful libraries.
How to use Aspose.Cells for creating Excel files in .NET
Using Aspose.Cells is quite simple. You need to add a reference to the Aspose.Cells.dll, create an instance of the Workbook class, get a Worksheet instance (either use the existing sheet or create a new one) and use the Cells indexer to access a cell. Set the value of cells using the PutValue method. Finally, generate the Excel file using the Save method of the Workbook class. Here's an example:
//using Aspose.Cells; //add this to the top of your file
Workbook wb = new Workbook();
Worksheet ws = wb.Worksheets[0];
ws.Cells[0,0].PutValue("Nitin");
ws.Cells[1,0].PutValue("Reddy");
wb.Save("File1.xls", FileFormatType.Excel2003);
If you are using Aspose.Cells in an ASP.NET application, you can simply save the document for the user to download by replacing the above wb.save statement with the one below:
wb.Save("File1.xls", FileFormatType.Excel2003, SaveType.OpenInExcel, Response);
Respose.End();
You can also use Aspose.Cells to directly save a DataTable (System.Data.DataTable) to an Excel file by inserting values into the worksheet like this:
ws.Cells.ImportDataTable(myDataTable, true, "B2");
The "true" value indicates that the column names of the data table will also be written to the worksheet and the "B2" indicates the cell from which the copy will begin.
How to use Aspose.Words for creating Word files in .NET
Using Aspose.Words was a little challenging for me to get started as the demos provided on the Aspose website do not provide examples of creating MS Word files from scratch, but rather focus on demonstrating the ability to load an existing Word file as a template and building upon it. As is the case with the Workbook object in Aspose.Cells, you have to begin by creating a Document object and creating a DocumentBuilder. You can then use the Write, Writeln, and InsertHtml methods of the DocumentBuilder class to create the document and the Save method of the Document class to write to a file or a Respose stream.
Here's an example:
//using Aspose.Words; //add this to the top of your file
Document doc = new Document();
DocumentBuilder bld = new DocumentBuilder(doc);
bld.Writeln("Nitin Reddy");
bld.InsertHtml("<b>Location:</b> Dubai<br />");
bld.Write("-----");
doc.Save("File1.doc", SaveFormat.Doc);
When using this in an ASP.NET application to serve files to client browsers, simply replace the above doc.Save method call with the following:
doc.Save("File1.doc", SaveFormat.Doc, SaveType.OpenInWord, Respose);
Respose.End();
Subscribe to:
Posts (Atom)