Monday, February 7, 2011

What is maximum upload file size in asp.net, and how to set up, MaxRequestLength

What is maximum upload file size in asp.net, and how to set up,  MaxRequestLength
You can change this setting in web.config:
<system.web>
  <httpRuntime  maxRequestLength="102400" executionTimeout="360"/>
</system.web>

If this attribute set to limited size, can be used to prevent denial of service attacks (DOS).

Default value:  4096 (4 MB).
Maxium size:  1048576 (1 GB) for .NET Framework 1.0/1.1 and 2097151 (2 GB) for .NET Framework 2.0.

Reference:
http://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.maxrequestlength.aspx

Sunday, February 6, 2011

Understand Lambda and anonomous function by reading code

Example code for anonomous function
Before
button1.Click += new EventHandler(button1_Click);
void button1_Click (object sender, EventArgs e)
{
textbox1.Text = DateTime.Now.ToShortDateString();
}

After Lambda Code:
button1.Click += (s, e) => { textbox1.Text = DateTime.Now.TosShortDateString(); } ;

Understand LINQ by reading code (1)

Source
1. Add references:
using System.Data.Linq;
using System.Data.Linq.Mapping;

2. Connect to database:
DataContext db = new DataContext

3. Mapping table and class
[Table(Name = "Customers")]
public class Customer
{
}

4. Query:
Table<Customer> Customers = db.GetTable<Customer>();
IQueryable<Customer> custQuery =
from cust in Customers
where cust.City == "London"
select cust;
foreach (Customer cust in custQuery)
{
Console.WriteLine("ID={0}, City={1}", cust.CustomerID,
cust.City);
}

Saturday, February 5, 2011

How to publish a asp.net website in Windows 7

1. install the "IIS Metabase and IIS6 Configuration Compatibility" feature under Internet Information Services-Web Management Tools-IIS 6
2. FrontPage 2002 Server Extensions for IIS 7.0
http://www.iis.net/community/default.aspx?tabid=34&g=6&i=1630
3. Compile code to AnyCPU in Build option

Friday, February 4, 2011

How to remove one element from array in Javascript?

How to remove one element from array in Javascript?
myArray = ['a', 'b', 'c', 'd'];
myArray.splice (
0,1);
[
'b', 'c', 'd'];
Reference