Yearly Archives - 2008

SQL Injection

It is a way of hacking on a database driven application in which the hacker executes unauthorized SQL commands by taking advantage of insecure code on a system connected to the Internet, bypassing the firewall. SQL injection hackers are used to steal information from a database from which the data would normally not be available...

Export to excel in ASP.NET using C#

In this article we are going to show two examples of exporting to excel. First one is how to export grid view control to excel and the second one is how to export data table to excel. 1-Export Grid View control to Excel: HtmlForm htmlForm = new HtmlForm(); string fileName = "attachment; filename=Reports.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", fileName); Response.ContentType = "application/ms-excel"; StringWriter strw...

Send email using C#

We are going to use Gmail outgoing mail server in our code here to demonstrate how you can send an email from your application using C# SmtpClient oSmtpClient = new SmtpClient(); oSmtpClient.Host = "smtp.gmail.com"; //The Outgoing mail server oSmtpClient.Credentials = new NetworkCredential("Your Email", "Your password"); oSmtpClient.Port = 587; oSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; oSmtpClient.EnableSsl = true; MailMessage msg = new MailMessage("Email From", "Email...

Difference between 3 tiers and 3 layers applications

The terms tier and layer are frequently used interchangeably, but actually there is a difference between them: Tiers indicate a physical separation of components, which may mean different assemblies such as DLL, EXE, etc... on the same server or multiple servers; but layers refers to a logical separation of components, such as having distinct namespaces...

Captcha image in C#.NET

What Captcha stand for? Completely Automated Public Turing test to tell Computers and Humans Apart. The Captcha technology help you to make sure your site is reasonably secure against automated attacks. Write the following code in a class named Captcha: public class Captcha { //make the captcha image for text public Bitmap MakeCaptchaImage(string txt, int width, int hight,...

The difference between Server.Transfer and Response.Redirect in ASP.NET

Server.Transfer processes the page from one page directly to the next page without making a round-trip back to the client's browser. This way is faster, with a little less overhead on the server. However, it does not update the clients URL history list or current URL. Response.Redirect, as expected, is used to redirect the user's...