Archive for September, 2011

ASP.NET Session State

Posted: September 21, 2011 in ASP.NET
Tags: ,

Default value is – 20 minutes and it can be increased to maximum of 24 hours or 1440 minutes.

You can change default value @ web.config level or IIS web site level.

http://forums.asp.net/t/1283350.aspx

http://msdn.microsoft.com/en-us/library/ms972429.aspx

IIS 6.0 Resource Kit – contains a utility called SelfSSL.exe for instantly creating and installing a self-signed testing certificate into IIS.  The tool is intended for IIS 6.0, but it works on IIS 5.1 also and it is simple to use.

  • Download IIS 6.0 Resource Kit Tools
  • Install the resource kit (requires Windows Server 2003, Windows XP)
    From the Windows Start Menu, go to the “\Programs\IIS Resources\SelfSSL” folder and select “SelfSSL”.
  • Instructions will be listed in a command prompt. Type “selfssl” to run the program.
  • Type “y” to confirm overriding/installing the certificate on the given site.
  • Test that it worked by visiting https://localhost/.

References

Step by step instructions to setup – http://www.visualwin.com/SelfSSL/

Download resource kit from http://www.microsoft.com/download/en/details.aspx?DisplayLang=en&id=17275

Book related to resource kit – http://www.addall.com/New/BestSeller.cgi?isbn=0735614202&dispCurr=USD

http://dotnetslackers.com/articles/ado_net/Managing-Entity-Framework-ObjectContext-lifespan-and-scope-in-n-layered-ASP-NET-applications.aspx

http://code.msdn.microsoft.com/EFProviderWrappers-c0b88f32

http://msdn.microsoft.com/en-us/library/system.data.objects.objectstatemanager.aspx

On setting the lazy loading attribute to true (Lazy loading property is on edmx file’s context object) helps to provide lazy loading of related entities data instead of loading them on the same time when the main entity is accessed.

Through .NET CLR Support in SQL Server –  http://www.codeproject.com/KB/database/xp_pcre.aspx

Through .NET CLR Support in SQL Server + Deploy using Visual Studio’s SQL Server Project – http://www.codeproject.com/KB/database/SqlRegularExpressions.aspx

Through .NET CLR Support in SQL Server (msdn link) – http://msdn.microsoft.com/en-us/magazine/cc163473.aspx

Using OLE Fn (SQL Server 2000) – http://www.simple-talk.com/sql/t-sql-programming/tsql-regular-expression-workbench/

Default pattern matching support in SQL Server – http://msdn.microsoft.com/en-us/library/ms187489(SQL.90).aspx

http://support.microsoft.com/kb/139444

http://www.barebonescoder.com/2010/06/mstest-vs-nunit-with-visual-studio-2010-tdd/

http://www.barebonescoder.com/2011/03/mstest-vs-nunit-with-visual-studio-2010-tdd-redux/

http://osherove.com/blog/2010/3/5/nunit-vs-mstest-nunit-wins-for-unit-testing.html

http://microsoftnlayerapp.codeplex.com/

http://msdn.microsoft.com/es-es/architecture/en/

JSON to C# object to JSON

Posted: September 8, 2011 in C#, Javascript, JQuery, JSON
Tags: , , ,

[DataContract]
public class SearchFilter
{
[DataMember]
public string SearchCol { get; set; }
[DataMember]
public string SearchOp { get; set; }
[DataMember]
public string SearchText { get; set; }
[DataMember]
public int PageNo { get; set; }
}
using System;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;
public class JSONHelper
{
public static T Deserialise<T>(string json)
{
T obj = Activator.CreateInstance<T>();
using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json)))
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());
obj = (T)serializer.ReadObject(ms);
ms.Close();
return obj;
}
}

public static string Serialize<T>(T obj)
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());
using (MemoryStream ms = new MemoryStream())
{
serializer.WriteObject(ms, obj);
return Encoding.Default.GetString(ms.ToArray());
}
}
}
Usage –

SearchFilter lSearchFilter = JSONHelper.Deserialise<SearchFilter>(“{‘SearchCol’:’Col1′,’SearchOp’:’contains’,’SearchText’:’hi’}”);
lSearchFilter.SearchCol
lSearchFilter.SearchOp

function ToJSONKeyValueFormat(pKey, pValue, pIsString) {
return ((pIsString)? (“\”” + pKey + “\”:\”” + pValue + “\””) : (“\”” + pKey + “\”:” + pValue));
}
function ToJSONFormat() {
var lJSONString = “”;
for (var i = 0; i < arguments.length; i++) {
lJSONString = ((i === 0)? “{” + arguments[i] : lJSONString = lJSONString + “,” + arguments[i]);
}
return ((lJSONString !== “”) ? lJSONString + “}” : “”);
}

Usage:

ToJSONFormat(ToJSONKeyValueFormat(“Key1”, “Val1”, true), ToJSONKeyValueFormat(“Key2”, 2, false))

Output:

{\”Key1\”:\”Val1\”,\”Key2\”:2}

BIDS is only provided with the (not free) Standard, Enterprise and Developer Editions
 
SQL Server 2005 Express Edition does not include SSIS or the Business Intelligence Development Studio.

To get BIDS on SQL Server Express Edition use – SQL Server 2005 Express Edition Toolkit
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=19413