I’ve gotten a lot of use during my time coding with ASP.NET out of inheriting from IHttpHandler. I usually do this to handle dynamically-generated files in various formats (PDF, XLSX, and images to name a few). One thing that always irked me was the inability to access the HttpContext’s SessionState object to get things like connection strings and information about the logged-in user more easily to aid in generating my files; often I would end up encrypting those and cramming them into the query-string, which can present challenges such as replay attacks that I’d then have to find a way to prevent.
Archive for the ‘Code Samples’ Category
A while back I was putting together a website that, among other things, relied on being able to retrieve products from Amazon’s Product Advertising API. There isn’t a ton of documentation out there on how to do this, and it took me a long time to find information on how to do this in my language of choice, C#. Unfortunately, there isn’t anything as cool as the Zend Framework for .NET.
For a while now, I’ve had a website that was sporadically encountering the following error:
Last time we discussed Serializing Data with System.Xml.Serialization.XmlSerializer. We will be using the same sample solution for this article.
Serializing objects is often a useful way to save the state of an application. Let’s take a look at doing this using the XmlSerializer object.
The .Net Framework makes version checking extremely simple. The framework provides a Version class that implements IComparable. Comparing two versions is as easy as the code below:
I had to write a method to put images onto PDFs generically, so I wrote this handy little method. Just get your PDF and your image into byte arrays and fire the method below. I used PDFSharp to append the image. This method could be used to do things like build a letterhead generator or any other kind of PDF document generation.
Relaying information snippets and error messages is one of the most common tasks between web application developers. The most basic control this can be done with is the Literal. That’s great for an internal application or a school project, but in the real world information has to be both visually appealing and convey what the message is about using an icon or other form of illustration.