my.net

My Photo
Name:
Location: United States

Tuesday, May 30, 2006

Session - cookieless and mode

Session management in ASP.NET can be done in two ways:

Using Cookies
Encoding of URLs with Session ID



URL encoding/mangling cannot be used with full-path URL’s as in:


it should be:



ASP.NET supports three modes of session state:
InProc:

StateServer: uses a stand-alone Microsoft Windows service to store session variables. performance is impacted when you cross process boundaries.

SqlServer: use SqlServer mode to leverage Microsoft SQL Server to ensure the highest level of reliability. SqlServer mode is similar to out-of-process mode, except that the session data is maintained in a SQL Server.

Note You can use all three modes with in-memory cookie or cookieless session ID persistence.

Session - cookieless and mode

Session management in ASP.NET can be done in two ways:

Using Cookies
Encoding of URLs with Session ID



URL encoding/mangling cannot be used with full-path URL’s as in:


it should be:



ASP.NET supports three modes of session state:
InProc:

StateServer: uses a stand-alone Microsoft Windows service to store session variables. performance is impacted when you cross process boundaries.

SqlServer: use SqlServer mode to leverage Microsoft SQL Server to ensure the highest level of reliability. SqlServer mode is similar to out-of-process mode, except that the session data is maintained in a SQL Server.

Note You can use all three modes with in-memory cookie or cookieless session ID persistence.

Session - cookieless and mode

Session management in ASP.NET can be done in two ways:

Using Cookies
Encoding of URLs with Session ID



URL encoding/mangling cannot be used with full-path URL’s as in:


it should be:



ASP.NET supports three modes of session state:
InProc:

StateServer: uses a stand-alone Microsoft Windows service to store session variables. performance is impacted when you cross process boundaries.

SqlServer: use SqlServer mode to leverage Microsoft SQL Server to ensure the highest level of reliability. SqlServer mode is similar to out-of-process mode, except that the session data is maintained in a SQL Server.

Note You can use all three modes with in-memory cookie or cookieless session ID persistence.

Fiddler HTTP Debugger - Fiddler

Fiddler HTTP Debugger - Fiddler

Fiddler is a HTTP Debugging Proxy which logs all HTTP traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP Traffic, set breakpoints, and "fiddle" with incoming or outgoing data. Fiddler is designed to be much simpler than using NetMon or Achilles, and includes a simple but powerful JScript.NET event-based scripting subsystem.

Terminal Services

c:> qwinsta
- command to get all the terminal sessions

Improve string concatenation performance

How to improve string concatenation performance in Visual Basic .NET or in Visual Basic 2005

The .NET Framework includes a StringBuilder class that is optimized for string concatenation. It provides the same benefits as using the Mid statement in previous versions of Visual Basic, as well as automatically growing the buffer size (if needed) and tracking the length for you.

Saturday, May 20, 2006

Angel Saenz-Badillos : ADO.NET new for 2.0, Clearing the pool on Server recycle

Angel Saenz-Badillos : ADO.NET new for 2.0, Clearing the pool on Server recycle

Tuesday, May 09, 2006

gc.collect

If you have a particular niche scenario where you have to call GC.Collect, consider the following:

Call GC.WaitForPendingFinalizers after you call GC.Collect. This ensures that the current thread waits until finalizers for all objects are called.
After the finalizers run, there are more dead objects (those that were just finalized) that need to be collected. One more call to GC.Collect collects the remaining dead objects.
System.GC.Collect(); // This gets rid of the dead objects
System.GC.WaitForPendingFinalizers(); // This waits for any finalizers to finish.
System.GC.Collect(); // This releases the memory associated with the objects that were just finalized.

why interop MSMQ

From: Doron Juster [MSFT] - view profile
Date: Sat, Jan 15 2005 12:45 pm
Email: "Doron Juster [MSFT]"




I'm afraid that with present version of the .net framework you may need to
use COM intertop in order to use msmq cursor or lookupid. (lookupid is
available on WindowsXP and later).
These features will be available natively in the next version of .net
framework.

thanks, Doron

transaction queue send

14.1 I am using an internal transaction to send a message and the message does not enter the queue. Why?
A common mistake is to use code similar to the following:
MyQueue.Send(Str,"My Message Data.", new
MessageQueueTransaction());
This is incorrect because the internal transaction is never committed, so the message is never sent. You need to create a MessageQueueTransaction object before calling Send, and then commit it. Alternatively, you can use MessageQueueTransactionType.Single.

MSMQ beginpeek endless loop

14.8 Calling BeginPeek from the delegate handler routine (after calling EndPeek to complete a previous BeginPeek call) results in an endless loop of peeking the same message. Why?
The current version of System.Messaging does not provide an asynchronous cursor that will let you peek the next message in a loop, asynchronously. A BeginPeek/EndPeek loop will peek the same message again and again. This is because BeginPeek always peeks the first message in a queue. If that message is not removed after a preceding EndPeek, the loop will keep peeking that same first message. You should consider using MessageQueueEnumerator.

Wednesday, May 03, 2006

Why do I have to use the STAThread attribute for m...

While the STAThread is required (as the documentation states) and pertinent only to applications that use COM interop, 1.0 version of the .Net framework has some bugs that makes it necessary for you to specify the STAThread attribute:
1) Ole Drag Drop will not work without STA. You can check this by turning on drag and drop in a form and try to run it.
2) Invoking a method in a type using Reflection will not work either.
These bugs have however been resolved in the 1.1 version of the framework (Everett). Which means you then do not have to specify this attribute for your main method. "

is and as operator in C#

try
{
DataGridItem d = (DataGridItem)obj.Parent;
if (d.GetType() == “DataGridItem”)
{
// Do something with d
}
}
catch (InvalidCastException e)
{

}

Using “as”



DataGridItem d = obj.Parent as DataGridItem;

if (null != d)
{
// Do something with d
}


Using the example for the “as” operator, consider this statement:

DataGridItem d = obj.Parent as DataGridItem;

if (d is DataGridItem)
{
// Do something with d
}

The difference, as you probably noticed, is that in the “as” example d is compared for inequality against null, whereas in the “is” example it was compared against the type in question. Using “is” is more intuitive, more readable, and slightly more efficient, making it by far the better choice.


Using “is” and “as” result in fewer lines of IL and fewer lines of actual C# code by avoiding a lot of extraneous checks and statements,

Tuesday, May 02, 2006

In Search Of ASP.Net Controls

Tips for locating controls with the FindControl method, including finding controls in DataGrid rows, Repeaters, DataGrid headers, and user controls

more at:
http://www.odetocode.com/Articles/116.aspx

FindControl method -
Searches the current naming container for the specified server control.

Here we can see there are many instances of TextBox1, but each ID is prefixed with some additional identifier information. This behavior shows the INamingContainer objects at work. The DataGrid implements INamingContainer and will preface each child control ID with ‘DataGrid1’. As we will see shortly, a DataGrid uses a collection of DataGridItem controls to represent each row of data. A DataGridItem control also implements INamingContainer, and will preface the name of child controls with a it’s own generated identifier (‘_ctrl2’, ‘_ctrl3’, etc.).


to get controls in the footer...
int footerIndex = DataGrid1.Controls[0].Controls.Count-1;
d = DataGrid1.Controls[0].Controls[footerIndex].FindControl("DropDownList1") as DropDownList;