Asp.Net

Web Application Error Handling and Logging For ASP

Thursday, January 10th, 2008

Up until .NET there was no real error handling in ASP code. Sure, you have your "On Error Resume Next" and "On Error Goto 0", but there was no good structured error handling. I can truly say there has not been one Web application I have come across of decent ...

Hot To Convert String Encoding For Database Use?

Tuesday, September 4th, 2007

Sometimes when you try to input text into database from your C# applications, some of the characters don't show up or show up differently. For Example: apostrophe(') is very often replaced by question mark(?). The same thing happens when you try inserting chinese or japanese characters into database. The reason of ...

How To Remove “Bad” Html Tags From Text Using C#

Tuesday, September 4th, 2007

The following method removes unwanted html tags from text. It is very useful for removing malicious code from form inputs. // RemoveHTMLTags method removes *most* malicious code leaving allowed // HTML in placet public static string removeHTMLTags(string input) { string output = ""; // break the comments ...

How To Get IP Address From The Host Name

Monday, September 3rd, 2007

Use the following method to get IP address of the hostname: using System.Net; public string GetIPAddress(string sHostName) { IPHostEntry ipEntry = Dns.GetHostByName(sHostName); IPAddress [] addr = ipEntry.AddressList; string sIPAddress = addr[0].ToString(); return sIPAddress; }

Setting 301 Redirect - Complete Guide

Thursday, August 30th, 2007

301 Redirect is interpreted as "permanently moved". Setting a 301 redirect is the best and Search Engine Friendly method for redirecting a webpage. By using 301 redirect, you can move your files around, change file names and redirect your pages without losing your search engine rankings. 301 Redirect in Apache - ...

Handling errors and custom errors pages in ASP.Net.

Thursday, August 23rd, 2007

Good website has to have errors handling implemented. It looks good and it's very useful. You can set up sending emails with errors details after error occurs or save errors to database. There are three ways you can handle errors in your ASP.NET pages. 1. Page_Error Method You can set error handling ...

Setting The Default Button For A TextBox And Clearing A Textbox On Focus in ASP.NET

Friday, August 17th, 2007

Today I have for you two very simple, but very useful methods to use in your ASP.NET programming. First method is used to set a default button for the textbox. It's the best way to make your form submit on enter nad it's very useful if you have few forms on ...