Thursday, September 22, 2005

How to increase the request size limit and make possible the upload of larger files?

If you ever used the ASP.NET file upload control you may be
have noticed that if you try to upload a file which size
exceeds 4MB, the upload failes.
The reason for this is the ASP.NET precaution against
denial-of-service attacks which by default limits the
size of the requests at 4MB.
However if in your application you need to upload larger files
you may increase this limit, by simply modifying the
maxRequestLength attribute in your machine.config file
...

How to get the host name from an IP address?

public string getHost(string ip)
{
IPHostEntry IpEntry = Dns.GetHostByAddress(ip);
return iphostentry.HostName.ToString();
}

How to strip the HTML tags from text with C# and Regular expression?

string strResult = Regex.Replace(strInput,@"<(.|\n)*?>",string.Empty);