Friday, August 29, 2008

Prevent user from back to the previous page after logout

Problem: Prevent user from back to the previous page after logout.

Solution: For this scenario, my idea is to write a cookie when logout (check the “SetLogoutCookie” function), and read the cookie when page load for each web page except login.aspx (check the “RedirectToLoginPage” function). If the data in cookie means logout then redirect current page to login.aspx.

***** default.aspx ****** <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> <script type="text/javascript">

function SetLogoutCookie(value)

{

var exdate=new Date();

exdate.setDate(exdate.getDate()+1);

var expires = ";

expires=" + exdate.toGMTString();

document.cookie = "logout=" + value + expires+";

path=/";

}

function Checklogout() {

var c_start = document.cookie.indexOf("logout=");

if (c_start!=-1) { c_start=c_start + 7; c_end=document.cookie.indexOf(";",c_start)

if (c_end==-1)

{

c_end=document.cookie.length;

} if(document.cookie.substring(c_start,c_end)== "true")

{

return true; }

}

return false;

}

function RedirectToLoginPage() {

if (Checklogout()) { window.location = "login.aspx";

}

}

</script>

</head>

<body onload="RedirectToLoginPage()"> <form id="form1" runat="server">

<div>

<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" OnClientClick="SetLogoutCookie('true')">Log out </asp:LinkButton>

</div>

</form>

</body>

</html>

************* default.aspx.cs ********************************

protected void LinkButton1_Click(object sender, EventArgs e)

{

FormsAuthentication.SignOut();

FormsAuthentication.RedirectToLoginPage(); }

************ login.aspx ************************************

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>Untitled Page</title>

<script type="text/javascript">

function SetLogoutCookie(value)

{

var exdate=new Date();

exdate.setDate(exdate.getDate()+1);

var expires = "; expires="+exdate.toGMTString();

document.cookie = "logout=" + value + expires+";

path=/";

}

</script>

</head>

<body>

<form id="form1" runat="server">

<div>

Name:<asp:TextBox ID="TBName" runat="server">test</asp:TextBox>

<br />

Password:<asp:TextBox ID="TBPassword" runat="server" TextMode="Password"></asp:TextBox>

<br />

<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" OnClientClick="SetLogoutCookie('false')">Login</asp:LinkButton></div>

</form>

</body>

</html>

************ login.aspx.cs ***********************************

protected void LinkButton1_Click(object sender, EventArgs e)

{

if (FormsAuthentication.Authenticate(TBName.Text,TBPassword.Text))

{ FormsAuthentication.RedirectFromLoginPage(TBName.Text,false);

}

}

************ web.config **********************************

<authentication mode="Forms">

<forms name="appNameAuth" path="/" loginUrl="login.aspx"

protection="All" timeout="30">

<credentials passwordFormat="Clear">

<user name="test" password="test" />

</credentials>

</forms>

</authentication>

<authorization>

<deny users="?" />

</authorization>

Tuesday, June 24, 2008

SQL Optimization Tips

SQL Optimization Tips • Use views and stored procedures instead of heavy-duty queries. This can reduce network traffic, because your client will send to server only stored procedure or view name (perhaps with some parameters) instead of large heavy-duty queries text. This can be used to facilitate permission management also, because you can restrict user access to table columns they should not see. • Try to use constraints instead of triggers, whenever possible. Constraints are much more efficient than triggers and can boost performance. So, you should use constraints instead of triggers, whenever possible. • Use table variables instead of temporary tables. Table variables require less locking and logging resources than temporary tables, so table variables should be used whenever possible. The table variables are available in SQL Server 2000 only. • Try to use UNION ALL statement instead of UNION, whenever possible. The UNION ALL statement is much faster than UNION, because UNION ALL statement does not look for duplicate rows, and UNION statement does look for duplicate rows, whether or not they exist. • Try to avoid using the DISTINCT clause, whenever possible. Because using the DISTINCT clause will result in some performance degradation, you should use this clause only when it is necessary. • Try to avoid using SQL Server cursors, whenever possible. SQL Server cursors can result in some performance degradation in comparison with select statements. Try to use correlated sub-query or derived tables, if you need to perform row-by-row operations. • Try to avoid the HAVING clause, whenever possible. The HAVING clause is used to restrict the result set returned by the GROUP BY clause. When you use GROUP BY with the HAVING clause, the GROUP BY clause divides the rows into sets of grouped rows and aggregates their values, and then the HAVING clause eliminates undesired aggregated groups. In many cases, you can write your select statement so, that it will contain only WHERE and GROUP BY clauses without HAVING clause. This can improve the performance of your query. • If you need to return the total table's row count, you can use alternative way instead of SELECT COUNT(*) statement. Because SELECT COUNT(*) statement make a full table scan to return the total table's row count, it can take very many time for the large table. There is another way to determine the total row count in a table. You can use sysindexes system table, in this case. There is ROWS column in the sysindexes table. This column contains the total row count for each table in your database. So, you can use the following select statement instead of SELECT COUNT(*): SELECT rows FROM sysindexes WHERE id = OBJECT_ID('table_name') AND indid < 2 So, you can improve the speed of such queries in several times. • Include SET NOCOUNT ON statement into your stored procedures to stop the message indicating the number of rows affected by a T-SQL statement. This can reduce network traffic, because your client will not receive the message indicating the number of rows affected by a T-SQL statement. • Try to restrict the queries result set by using the WHERE clause. This can results in good performance benefits, because SQL Server will return to client only particular rows, not all rows from the table(s). This can reduce network traffic and boost the overall performance of the query. • Use the select statements with TOP keyword or the SET ROWCOUNT statement, if you need to return only the first n rows. This can improve performance of your queries, because the smaller result set will be returned. This can also reduce the traffic between the server and the clients. • Try to restrict the queries result set by returning only the particular columns from the table, not all table's columns. This can results in good performance benefits, because SQL Server will return to client only particular columns, not all table's columns. This can reduce network traffic and boost the overall performance of the query. 1.Indexes 2.avoid more number of triggers on the table 3.unnecessary complicated joins 4.correct use of Group by clause with the select list 5 In worst cases Denormalization Index Optimization tips • Every index increases the time in takes to perform INSERTS, UPDATES and DELETES, so the number of indexes should not be very much. Try to use maximum 4-5 indexes on one table, not more. If you have read-only table, then the number of indexes may be increased. • Keep your indexes as narrow as possible. This reduces the size of the index and reduces the number of reads required to read the index. • Try to create indexes on columns that have integer values rather than character values. • If you create a composite (multi-column) index, the order of the columns in the key are very important. Try to order the columns in the key as to enhance selectivity, with the most selective columns to the leftmost of the key. • If you want to join several tables, try to create surrogate integer keys for this purpose and create indexes on their columns. • Create surrogate integer primary key (identity for example) if your table will not have many insert operations. • Clustered indexes are more preferable than nonclustered, if you need to select by a range of values or you need to sort results set with GROUP BY or ORDER BY. • If your application will be performing the same query over and over on the same table, consider creating a covering index on the table. • You can use the SQL Server Profiler Create Trace Wizard with "Identify Scans of Large Tables" trace to determine which tables in your database may need indexes. This trace will show which tables are being scanned by queries instead of using an index. • You can use sp_MSforeachtable undocumented stored procedure to rebuild all indexes in your database. Try to schedule it to execute during CPU idle time and slow production periods. sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?')"

Thursday, June 12, 2008

How to Determine CompactFramework Version

If you are developing mobile application for Windows PocketPC and Windows Mobile using Microsoft Compact Framework, you may need to deploy Compact Framework to targeted mobile device in order to run your application. It is crucial to determine what version is currently installed on targeted device and if the installed version fits your application requirement. Different builds may work differently and thus may break your application if installed wrong version. How to Check If Compact Framework Already Installed on Mobile Device There are few ways to check if any compact framework has been installed. However, I will show you the basic ways to determine compact framework installation. 1. On your device, go to My Device -> Windows and run cgacutil.exe. The version will be displayed on screen. 2. Check if \Windows\mscoree.dll file exists. If this file is exists, that means the compact framework has been installed. Now you know Compact Framework already installed on the mobile device and want to know which revision and builds is being installed. How to Determine Compact Framework Version In order to check the version installed, you can access the registry key on targeted mobile. The registry key that you want to look at is HKLM\SOFTWARE\Microsoft\.NetCompactFramework All versions of Compact Framework installed will be listed in this key. Take not that all Compact Framework 1,2 and 3.5 (beta) can co-exists at the same time on the same mobile device. Thus, you may see both versions on the list if both versions already installed. For more information on what the revision number means, please refer to table below. Compact Framework Version List There are 2 tables below that list out all builds and revisions for Compact Framework 1.0 , Compact Framework 2.0 and Compact Framework 3.5. (There won’t be a CF 3.0). Compact Framework 1.0 1.0.2268.00 RTM 1.0.3111.00 SP1 1.0.3226.00 SP2 Recall 1.0.3227.00 SP2 Beta 1.0.3316.00 SP2 Final 1.0.4292.0 SP3
Compact Framework 2.0 2.0.5238.00 RTM 2.0.6129.0 SP1 2.0.7045.0 SP2
Compact Framework 3.5 3.5.7066.0 Beta 1 3.5.7121.0 Beta 2

Requirements for Pocket PC/ Windows Mobile to run .Net Application with SQL Server.

1) To Connect PDA to PC you need ActiveSync software . 2) After Mobile Connected with PC download the SQL Compact 3.1 SDK and coy these 3 cab files from C:\Program Files\Microsoft SQL Server Compact Edition\v3.1\SDK\bin\wce500\armv4i to your device: #sqlce30.wce5.armv4i.CAB #sqlce30.repl.wce5.armv4i.CAB #sqlce30.dev.ENU.wce5.armv4i.CAB 3)Install NetCFSetupv2.msi from PC. It will install .Net Compact framework 2.0 in both PC and Mobile. You can download 1>NetCFSetupv2.msi from Here 2>SSCEDeviceRuntime-ENU.msi from Here

Some Usefule links regarding Pocket PC development

http://pocketpccentral.net/!pocket_pcs.htm#phone http://www.microsoft.com/downloads http://msdn.microsoft.com/en-us/library/fkack1sx.aspx

How can I tell if my Pocket PC has a Pocket PC 2000/2002/2003 or a Windows Mobile 5 or 6 Operating System?

Q: How can I tell if my Pocket PC has a Pocket PC 2000/2002/2003 or a Windows Mobile 5 or 6 Operating System? A: To find out what Pocket PC version you are running follow the steps below: * Select Start, then Settings on your Pocket PC * Choose the System tab, then the About icon * If the copyright in the About screen is 2001 or later, then you have a Pocket PC 2002 or later Pocket PC device. * If the operating system version is 4.0 but less than 5.0 it is a Pocket PC 2003 or 2003 Device * If the operating system version is 5.0 but less than 5.2 it is a Windows Mobile 5 Pocket PC or Pocket PC Phone Device. * If the operating system version is 5.2 or greater is a Windows Mobile 6 device. Windows Mobile 6 comes in three variations: - Classic (touch screen, no phone capabilities) previously 'Pocket PC' - Standard (non-touch screen) previously 'Smartphone' - Professional (touch screen with phone) previously 'Pocket PC Phone Edition'

Wednesday, June 11, 2008

WinCE Problem - .Net compact framework 2.0 installation problem

Solution for following errors (for .net compact framework 2.0): 1) "Installation of netcfv2.wce4.armv4.cab was unsuccessful" in WinCE mobile 2) "This application requires a newer version of the microsoft .net compact framework than the version installed on this device" Normally this error comes when your mobile has older version of compact framework and you are trying to install .net application of newer version. SOLUTION: 1) Install or reinstall NetCFSetupv2.msi in desktop. It will install .net compact framework in both desktop pc and mobile. --have a good day.(RK)

Tuesday, May 27, 2008

Caching in ASP.NET

Abstract Caching can dramatically improve the performance of your application by storing the page output or application data across HTTP requests. In this article, Joydip discusses the different types of Caching in ASP.NET with lucid code examples.

Caching is a feature of ASP.NET that improves the performance of web applications by minimizing the usage of server resources to a great extent. This article discusses Caching, its types and contains some lucid code examples to illustrate On- Demand Data Caching.

What is Caching?

Caching is a feature that stores data in local memory, allowing incoming requests to be served from memory directly.

Benefits of Caching

The following are the benefits of using Caching

  • Faster page rendering
  • Minimization of database hits
  • Minimization of the consumption of server resources

Types of Caching

Caching in ASP.NET can be of the following types
  • Page Output Caching
  • Page Fragment Caching
  • Data Caching
  • Page Output Caching

This is a concept by virtue of which the output of pages is cached using an Output Cache engine and all subsequent requests are served from the cache. Whenever a new request comes, this engine would check if there is a corresponding cache entry for this page. If there is a cache hit, i.e., if the engine finds a corresponding cache entry for this page, the page is rendered from the cache, else, the page being requested is rendered dynamically.

This is particularly useful for pages that are static and thus do not change for a considerable period of time.

Page output caching can be implemented in either of the following two ways:

  • At design time using the OutputCache directive
  • At runtime using the HttpPolicy class

The following is the complete syntax of page output caching directive

<%@ OutputCache Duration="no of seconds"
Location="Any | Client | Downstream | Server | None"
VaryByControl="control"
VaryByCustom="browser |customstring"
VaryByHeader="headers"
VaryByParam="parameter" %>

The following statement is used to implement output caching in an aspx page at design time. The directive is placed at the top of the .aspx page.

<%@OutputCache Duration="30"
VaryByParam="none" %>

The duration parameter specifies for how long the page would be in cache and the VaryByParam parameter is used to cache different views of the page. In the code example above, the cache duration is 30 seconds. Cache duration is a required field, and must be set to an integer greater than zero. The VaryByParam parameter, which is also required, specifies whether the cached page would differ in versions based on any parameter. A value of * in the same parameter indicates that the page would be cached based on all the Get/Post parameters. We can also specify one or more Get/Post parameter(s). Hence, the same statement shown above can have the following variations. The VaryByParam parameter is particularly useful in situations where we require caching a page based on certain criteria. As an example, we might require to cache a specific page based on the EmployeeID.

<%@OutputCache Duration="30"
VaryByParam="*" Location = "Any"%>  

<%@OutputCache Duration="30"
VaryByParam="EmployeeID" Location = "Client" %>  
<%@OutputCache Duration="30"
VaryByParam="EmployeeID;Basic" %> 

The VaryByParam parameter can also have multiple parameters as shown in the example above.

The location parameter is used to specify the cache location, either the server of the client.

To set a page's cacheability programmatically we have to use the method Response.Cache.SetCacheability. This method accepts the following parameters

  • NoCache
  • Private
  • Public
  • Server

The code snippet below shows how to set a page’s cacheability programmatically:

Response.Cache.SetCacheability(HttpCacheability.Server);

Additionally we can set other properties which map to the same fields available when using the OutputCache directive on the page:

Response.Cache.SetExpires(DateTime.Now.AddSeconds(30));
Response.Cache.SetValidUntilExpires(true);
Response.Cache.VaryByParams["EmployeeID"]= true; 

Page Fragment Caching

This allows specific portions of the page to be cached rather than caching the whole page. This is useful in situations where we can have a page that contains both static and dynamic content. The following code depicts how this can be accomplished.

<%@ OutputCache Duration="15"
VaryByControl="EmpID;DeptID" VaryByParam="*"%>   

This directive is placed at the top of any User Control (.axcx file).

Data Caching

The following code is an implementation of On-Demand caching. The method GetUserInfo checks to see if the data exists in the cache. If it is present, it is returned from the cache, else, the GetUserInfoFromDatabase method fills the DataSet from the database and then populates the Cache.

public DataSet GetUserInfo()
{  

  string cacheKey = "UserInfo";  
  DataSet ds = Cache[cacheKey] as DataSet;  
  if (ds == null)  

 {    
   ds = GetUserInfoFromDatabase();    
   Cache.Insert(cacheKey, ds, null, NoAbsoluteExpiration,      
   TimeSpan.FromHours(15),CacheItemPriority.High, null);  

}     
return ds;
}  

DataSet GetUserInfoFromDatabase() {
// Usual code to populate a data set from thedatabase. This data set 

// object is then returned. 
}

Cache Expirations

Cache expirations can be of the following types

  • Time Based Expiration
  • Dependency Based Expiration
  • Time Based Expiration

This is used to specify a specific period of time for which the page would remain in the cache. The following statement specifies such expiration for a page in the code behind of a file using C#.

Response.Cache.SetExpires(DateTime.Now.AddSeconds(120));
This can also be accomplished by stating the same in the output cache directive as shown here.
<%@OutputCache Duration="60"
VaryByParam="None" %>

Cache Expiration

Cache expiration strategies can be implemented in either of the following two ways:
  • Time Based
  • File Based
  • Key Based
Time Based Expiration

This is implemented by specifying a specific duration for which the item would remain in the cache. When the time elapses, the item is removed from the cache and subsequent requests to retrieve the item returns a null. Time based expiration strategies can be of the following two types:

  • Absolute
  • Sliding
  • Absolute
Cache.Insert("UserInfo", dsUserInfo, null,
DateTime.Now.AddMinutes(1), NoSlidingExpiration); 

Sliding

Cache.Insert("UserInfo", dsUserInfo, null,
NoAbsoluteExpiration,

TimeSpan.FromSeconds(60));

Note that you cannot use both Absolute and Sliding expirations at the same time.

File Based Expiration

This is implemented by using a file as a dependency. Whenever the contents of the dependency file are changed, the cached is invalidated. Please refer to the code below.
CacheDependency cacheDependency = newCacheDependency("userinfo.xml");
Cache.Insert("UserInfo", xmldocObject,cacheDependency); 
In addition to files, entire folders can be monitored for changes using the CacheDependency class.

Key Based Expiration

The third type of dependency is the key dependency. With it, a cache entry can be made to depend on another, existing dependency. When the depended-upon entry changes or expires, the dependent entry will also be expired. An array of keys can be specified as a single CacheDependency.
string[] keys = new string[] {"key"};
CacheDependency cacheDependency = newCacheDependency(null,keys);
Cache.Insert("UserInfo", xmldocObject,cacheDependency);

Using Callbacks

The delegate CacheItemRemovedCallback event handler is used to respond to the event that is raised when an item is deleted from cache. This handler contains the code to populate / re-populate the cache. Please refer to the code snippet below.
public void onRemoveCallBack(string str, objectobj, CacheItemRemovedReason reason)
{  
   DataSet dataset = GetUserInfoFromDatabase();  

   Cache["userInfo"] = dataset;
} 

1. First declare a class variable onRemove as shown below.

private static CacheItemRemovedCallback onRemove = null; 

2. This delegate is invoked as shown below.

onRemove = newCacheItemRemovedCallback(this.onRemoveCallBack);

3. The following code snippet shows how this handler is specified when items are added to the Cache.


Cache.Insert("userInfo", ds, null, DateTime.Now.AddMinutes(2),
NoSlidingExpiration, CacheItemPriority.High,
CacheItemPriorityDecay.Slow, onRemove);

The Cache Class

The Add/Insert method of the Cache class is used to add/insert an item into the cache. The Remove method removes a specified item from the cache. The Cache class contains the following properties and methods.

Properties

  • Count
  • Item

Methods

  • Add
  • Equals
  • Get
  • GetEnumerator
  • GetHashCode
  • GetType
  • Insert
  • Remove (Overloaded)
  • ToString
Conclusion Judicious use of the right type of caching can dramatically improve the performance of web applications. For more information about caching, please visit the ASPAlliance Caching

Microsoft .NET Terminologies at a Glance

Abstract This article defines many important terminologies that are related to Microsoft .NET so as to enable the reader to have a ready guide to the technical terms. Terminologies related to Microsoft .NET Framework, ASP.NET, ADO.NET, XML, Biztalk Server, etc. are covered. This will also help readers prepare themselves to go into interviews confidently. Overview [ Back To Top ] My objective in designing this article is to put an end to the arduous struggle of an IT professional seeking an understandable resource for the core terminologies of Microsoft.NET. Let me save you valuable time and energy by providing you with an article that gives you many of the important terminologies in Microsoft .NET and its related technologies. This article discusses most of the important terminologies related to Microsoft .NET Framework, ASP.NET, ADO.NET, Remoting and Web Services. The terminologies are not organized in an alphabetical order, rather they are organized in the order of the categories that they belong to. The Common Language Specification This is a subset of the Common Type System (CTS) and defines a set of conventions that are targeted at language interoperability of all the languages that run within the .NET environment. The Common Type System The Common Type System (CTS) is a standard that defines the necessary rules for type interoperability for the languages targeting the .NET environment. The common type system supports the following types. · Value Types · Reference Types .NET Framework Class Library The .NET Framework Class Library (FCL) is a set of managed classes that are responsible for providing access to the system services in the managed environment of Microsoft.NET. The Common Language Runtime The CLR is a runtime execution engine of .NET that provides an environment to execute programs that are targeted at the .NET platform. It provides memory allocation, security, code verification, type verification, exception handling and garbage collection in the managed environment. Common Language Infrastructure The Common Language Infrastructure or the CLI provides support for language interoperability in the .NET managed environment. It is comprised of the following features. · A File Format (PE) · Metadata · MSIL · Base Class Library Assembly An assembly is a group of resources and types, along with the metadata about those resources and types, deployed as a single unit. Just In Time Compiler The Just In Time Compiler or the JIT is responsible for compiling units of code and caching them at runtime as and when they are needed. Since the compilation occurs at runtime, it is known as a Just In Time Compilation. MSIL A program compiled in the .NET managed environment generates an intermediate code to support platform independence. This is called the MSIL or Microsoft Intermediate Language. Strong Name A Strong Name is a unique identifier given to an assembly using cryptography and a digital signature that is used to identify a particular assembly. An assembly is provided a strong name using the utility called sn.exe. A strong name consists of the following. · Name of the Assembly · Digital Signature · Version Number · Culture Information Global Assembly Cache The Global Assembly Cache is a system wide storage of shared assemblies. Assemblies can be stored or moved to and from the Global Assembly Cache using a tool called GacUtil. Managed Code A managed code is one that provides restricted access to the system’s resources and can be executed only in a managed environment that is provided in Microsoft .NET by the Common Language Runtime. Un-Managed Code An Un-Managed code is one that executes outside of the Common Language Runtime environment and can perform unsafe operations. Managed Data Managed Data refers to the objects that are created by the Common Language Runtime environment and can be garbage collected implicitly by the Garbage Collector. Shared Assembly A Shared Assembly is one that can be referred by more that one application. All shared assemblies should contain a strong name and should be located in the Global Assembly Cache (GAC). Private Assembly A Private Assembly is one that is private to one application. In other words, it can be accessed by the containing application only. Satellite Assembly When you wish to localize the application, it can be written in culture-neutral code and can distribute the localized modules in separate assemblies called satellite assemblies. Assembly Manifest The Assembly Manifest contains the information about an assembly. This includes the version number of the assembly, the list of the files that comprise the assembly, etc. An assembly manifest is contained in the dll file or the exe file itself. Resource A resource refers to an addressable unit of data that is available for use by an application. It consists of one or more of the following. · Texts · Files · Documents · Images · The .NET tool called resgen.exe is used to create resource files from the resource information that is stored in text or XML files. Localization Localization is the practice of designing and developing software that will properly use all of the conventions defined for a specific locale. An assembly that is used to provide localization feature in ASP.NET applications is referred to as a Satellite Assembly. Native Image Generator This is a .NET tool that is used to compile a managed assembly to the native code and then store that in the local assembly cache. The name of this tool is Ngen.exe. Value Type A value type is one that contains the value rather than the reference and is stored in the stack memory. Examples of value types are integers, floats, doubles, structures, etc. Reference Type A reference type contains a reference to the actual object in memory and is stored in the managed heap. Objects of classes are good examples of reference types. Boxing Boxing refers to the conversion of a value type to a reference type. Value types are stored in the stack and reference types are stored in the managed heap. Un-Boxing This refers to the conversion of a reference type to a value type. Garbage Collection Garbage Collection is a technique introduced in Microsoft .NET that manages memory cleanup implicitly. This implicit reclaiming of memory in the .NET managed environment is handled by the Common Language Runtime. Dispose Method The Dispose method can be used in an unsealed class to cleanup resources explicitly. It should be noted that both the Dispose and the Finalize methods should make a call to their parents' respective methods after they have disposed or finalized their own members. A class that needs to have this method implemented should implement the IDisposable interface. Finalize Method The finalize method is a protected member of the Object class and is implicitly called at the runtime to cleanup unmanaged resources before the object is destroyed. Code Verification This is a feature that enforces type safety or type security by checking the code prior to its execution in the run time environment. Therefore, it does not allow malicious code to get executed in the managed environment. Authentication and Authorization This is a security measure that is used to specify the user’s identity and authorization in ASP.NET. The process of authorization determines whether an authenticated user has access to a specific resource. Authentication and Authorization details of an ASP.NET application are specified in the web.config file. There can be three types of authentication in ASP.NET. · Forms Authentication · Windows Authentication · Passport Authentication Web.Config File The web.config file is the configuration file for an ASP.NET web application. Typically, the following information is stored in a web.config file. · Database Connection Strings · Security · Session States · Impersonation · Error handling Machine.Config File The machine.config file contains the configuration settings for the entire application and is located in the Config sub-folder of the Microsoft .NET installation directory. ASP.NET ASP.NET is a language neutral, interoperable, server-side technology that allows creation, execution and deployment of scalable Web Applications and Services. Caching Caching is a feature that stores the data in the memory for serving the incoming requests from the memory itself. Caching in ASP.NET can be of three types. · Page Output Caching · Page Fragment Caching · Data Caching Singleton Pattern A singleton pattern states that we can have a singleton class that can be instantiated only once in the application domain and provides a global point of access to it. Application Domain An application domain refers to the logical and physical boundary created around every .NET application. An application domain is created by the Common Language Runtime and supports execution of multiple .NET applications in the same process by isolating them in different application domains. View State This is a client-side state management technique that continues the state of server controls by maintaining the state of pages across postbacks. The view state is an encoded hashed string and is stored in a hidden field called __VIEWSTATE. Session State A session is the period of a connection between a server and a client. The Session State allows storage of objects in a user’s session. A session can be stored in one of the following ways. · InProc · State Server · SQL Server Application State This is a state management technique that allows objects to be stored and then globally accessed or shared by multiple modules of the application. In ASP.NET, application state is maintained by the class HttpApplicationState. Interface Definition Language (IDL) The Interface definition Language (IDL) defines a protocol between the server and the client so that they can communicate in heterogeneous environments. Universal Description, Discovery and Integration (UDDI) Universal Description, Discovery and Integration is a platform independent, XML based, distributed directory that allows the enterprises to list themselves over the internet. The UDDI business registration contains the following features. · Green Pages · White Pages · Yellow Pages Web Service Description Language (WSDL) The Web Service Description Language (WSDL) defines XML based contract services for describing the network services as a collection of communication end points. A WSDL document contains the following. · Messages · Operation · Types · Service · Port and its type Simple Object Oriented Protocol (SOAP) This is an XML-based protocol that is used to exchange structured data and type information in a distributed environment. Web Services A web service is SOAP based, platform–independent software component that exposes itself through open communication channels of the web applications running on potentially different platforms. Remoting Remoting allows two processes, a Server and a Client, to inter-communicate in the same system, the same network or across networks. In Remoting, a server and client communicate using a Channel. Service Oriented Architecture Service Oriented Architecture is an architecture that provides a seamless Enterprise Information Integration between loosely coupled distributed applications or services over the network. Service A service is an implementation of a well-defined, self-contained, independent business functionality that accepts one or more requests and returns one or more responses through a well-defined, standard interface. Smart Client Architecture The Smart Client Architecture is a deployable, multi-platform architecture that allows local application to connect to a server based application using web services. It provides an adaptive and rich user interactive experience by using local resources. A Smart Client application can work in both connected and disconnected modes. ADO.NET ADO.NET is an object oriented data access technology that enables you to access data from a managed environment. It is essentially a collection of some classes used to communicate between an application and a database. Connection Pool A Connection Pool is a pool of available or ready-to-use connections. When a new connection is requested it is served from the connection pool if one exists. If not, a new connection is created. Connection Pooling improves the performance of applications to a large extent. DataProvider A DataProvider encapsulates the protocols that ADO.NET uses to interact with different types of databases. DataSet The DataSet is an in–memory, disconnected, XML compliant representation of the data. Data in a DataSet can be changed, unlike a DataReader which is read only. DataReader A DataReader is a connected, forward only, read only stream of data that is retrieved from the database. DataAdapter The DataAdapter is a bridge between the DataSet and the underlying database. It provides a set of methods and properties to move data between a database and its in-memory representation, the DataSet. DataView A DataView is a class that provides a customized view of the DataSet. It is typically used to sort or filter the rows. Command The Command object is used to send the SQL Statements to the database. Commands are used to insert data, retrieve data and execute stored procedures in the database. Connection The Connection object establishes a connection to the database using the user name, password and the database name as parameters. Transactions A transaction is a block of statements that guarantees that all or none of the statements in the block are executed. In ADO.NET, a transaction can be started by using the BeginTransaction() method on the currently active Connection. To commit the transaction, the method CommitTransaction() is used. In order to abandon the transaction, the method Rollback() is executed. Serialization This refers to the storage of an object into a persistent storage medium in a stream of bytes. The opposite is de-serialization and is used to retrieve a serialized object from a storage medium. Reflection This is a feature that allows us to inspect the metadata of an assembly at runtime. Reflection can be used to retrieve metadata information, such as the following. · Classes · Methods · Properties · Events Biztalk Server This is a set of Microsoft Server Applications that allow integration, automation and management of different server applications. Exchange Server This is a set of Microsoft Server Applications that are responsible for integrating messaging and data storage technologies. Commerce Server This is Microsoft’s Business Server that is used for managing and developing business web sites. Array An array is a collection of homogenous objects. It is a group of elements of the same type that share a common name. The size of an array is fixed and cannot be changed at runtime. ArrayList An ArrayList is a collection of heterogeneous elements- elements of different types. Unlike an array, its size can be changed dynamically. HashTable A HashTable is a collection of heterogeneous objects that can be referred using either an index or a key. Elements of an ArrayList can be referred to using an index only. COM+ COM+ or COM Plus is a distributed, transactional, component-based technology that can be used in a multi-tiered architecture and provides support for Object Pooling. Delegate A delegate is a managed function pointer that refers to a method. A multi-cast delegate is one that points to and can eventually fire off different methods. A delegate is used to implement event handling in Microsoft .NET. Event Handler An event handler is a method that is executed in response to an event. Exception An exception is an event that is generated as a result of a runtime error. An exception is handled using the exception blocks. An exception that cannot be handled is referred to as a fatal exception and causes the flow of execution of the current program to terminate unexpectedly. Try/Catch Block A try/catch block is used in exception handling and provides a mechanism to trap runtime errors that can occur on execution of the application. A try block contains the code that can generate a runtime error. The catch block contains statements that are executed once the appropriate exception has occurred. A try block can contain one or more catch blocks or a finally block. Finally Block A finally block is one that is executed irrespective of whether an exception occurs or not. Typically, it is used in Exception Handling mechanism to release resources. Namespace A namespace refers to a logical grouping of types or identifiers used in a program.

22 New Features of Visual Studio 2008 for .NET Professionals

1. LINQ Support

LINQ essentially is the composition of many standard query operators that allow you to work with data in a more intuitive way regardless.

LINQ

The benefits of using LINQ are significant – Compile time checking C# language queries, and the ability to debug step by step through queries.

2. Expression Blend Support

Expression blend is XAML generator tool for silverlight applications. You can install Expression blend as an embedded plug-in to Visual Studio 2008. By this you can get extensive web designer and JavaScript tool.

3. Windows Presentation Foundation

WPF provides you an extensive graphic functionality you never seen these before. Visual Studio 2008 contains plenty of WPF Windows Presentation Foundation Library templates. By this a visual developer who is new to .NET, C# and VB.NET can easily develop the 2D and 3D graphic applications.

Visual Studio 2008 provides free game development library kits for games developers. currently this game development kits are available for C++ and also 2D/3D Dark Matter one image and sounds sets.

4. VS 2008 Multi-Targeting Support

Earlier you were not able to working with .NET 1.1 applications directly in visual studio 2005. Now in Visual studio 2008 you are able to create, run, debug the .NET 2.0, .NET 3.0 and .NET 3.5 applications. You can also deploy .NET 2.0 applications in the machines which contains only .NET 2.0 not .NET 3.x.

5. AJAX support for ASP.NET

AJAX

Previously developer has to install AJAX control library separately that does not come from VS, but now if you install Visual Studio 2008, you can built-in AJAX control library. This Ajax Library contains plenty of rich AJAX controls like Menu, TreeView, webparts and also these components support JSON and VS 2008 contains in built ASP.NET AJAX Control Extenders.

6. JavaScript Debugging Support

Since starting of web development all the developers got frustration with solving javascript errors. Debugging the error in javascript is very difficult. Now Visual Studio 2008 makes it is simpler with javascript debugging. You can set break points and run the javaScript step by step and you can watch the local variables when you were debugging the javascript and solution explorer provides javascript document navigation support.

7. Nested Master Page Support

Already Visual Studio 2005 supports nested master pages concept with .NET 2.0, but the problem with this Visual Studio 2005 that pages based on nested masters can't be edited using WYSIWYG web designer. But now in VS 2008 you can even edit the nested master pages.

8. LINQ Intellisense and Javascript Intellisense support for silverlight applications

javascriptintellisense

Most happy part for .NET developers is Visual Studio 2008 contains intellisense support for javascript. Javascript Intellisense makes developers life easy when writing client side validation, AJAX applications and also when writing Silverlight applications

Intellisense Support: When we are writing the LINQ Query VS provides LINQ query syntax as tool tips.

9. Organize Imports or Usings: We have Organize Imports feature already in Eclipse. SInce many days I have been waiting for this feature even in VS. Now VS contains Organize Imports feature which removes unnecessary namespaces which you have imported. You can select all the namespaces and right click on it, then you can get context menu with Organize imports options like "Remove Unused Usings", "Sort Usings", "Remove and Sort". Refactoring support for new .NET 3.x features like Anonymous types, Extension Methods, Lambda Expressions.

10. Intellisense Filtering: Earlier in VS 2005 when we were typing with intellisense box all the items were being displayed. For example If we type the letter 'K' then intellisense takes you to the items starts with 'K' but also all other items will be presented in intellisense box. Now in VS 2008 if you press 'K' only the items starts with 'K' will be filtered and displayed.

11. Intellisense Box display position

javascriptintellisense

Earlier in some cases when you were typing the an object name and pressing . (period) then intellisense was being displayed in the position of the object which you have typed. Here the code which we type will go back to the dropdown, in this case sometimes programmer may disturb to what he was typing. Now in VS 2008 If you hold the Ctrl key while the intellisense is dropping down then intellisense box will become semi-transparent mode.

12. Visual Studio 2008 Split View

spit

VS 205 has a feature show both design and source code in single window. but both the windows tiles horizontally. In VS 2008 we can configure this split view feature to vertically, this allows developers to use maximum screen on laptops and wide-screen monitors.

Here one of the good feature is if you select any HTML or ASP markup text in source window automatically corresponding item will be selected in design window.

13. HTML JavaScript warnings, not as errors: VS 2005 mixes HTML errors and C# and VB.NET errors and shows in one window. Now VS 2008 separates this and shows javascript and HTML errors as warnings. But this is configurable feature.

14. Debugging .NET Framework Library Source Code:

Now in VS 2008 you can debug the source code of .NET Framework Library methods. Lets say If you want to debug the DataBind() method of DataGrid control you can place a debugging point over there and continue with debug the source code of DataBind() method.

15. In built Silverlight Library

silverlight

Earlier we used to install silverlight SDK separately, Now in VS 2008 it is inbuilt, with this you can create, debug and deploy the silverlight applications.

16. Visual Studio LINQ Designer

LINQ

Already you know in VS 2005 we have inbuilt SQL Server IDE feature. by this you no need to use any other tools like SQL Server Query Analyzer and SQL Server Enterprise Manger. You have directly database explorer by this you can create connections to your database and you can view the tables and stored procedures in VS IDE itself. But now in VS 2008 it has View Designer window capability with LINQ-to-SQL.

17. Inbuilt C++ SDK

Earlier It was so difficult to download and configure the C++ SDK Libraries and tools for developing windows based applications. Now it is inbuilt with VS 2008 and configurable

18. Multilingual User Interface Architecture - MUI

MUI

MUI is an architecture contains packages from Microsoft Windows and Microsoft Office libraries. This supports the user to change the text language display as he wish.

Visual Studio is now in English, Spanish, French, German, Italian, Chinese Simplified, Chinese Traditional, Japanese, and Korean. Over the next couple of months. Microsoft is reengineering the MUI which supports nine local languages then you can even view Visual studio in other 9 local languages.

19. Microsoft Popfly Support

popfly

Microsoft Popfly explorer is an add-on to VS 2008, by this directly you can deploy or hosting the Silverlight applications and Marshup objects

20. Free Tools and Resources

People may feel that I am a promoter to Visual Studio 2008 as a salesman, but we get plenty of free resources and free tools with Visual Studio 2008.

  • Visual Studio 2008 Trial
  • 101 LINQ Samples
  • Free .NET 3.5 control libraries with free sample programs,
  • You can get plenty of free video training tutorials from Microsoft BDLC - Beginner Developer Learning Center,
  • C++ games development library,
  • Microsoft has provided lot of e-Books,
  • P2P library and
  • Microsoft is providing Coding4Fun sample program kit.
  • Visual Studio Registration Discounts: If you register the Visual Studio you get Free Control Libraries, Books, Images, and Discounts.
  • Download Visual Studio 2008 free trial

    21. We can use for Commercial

    Earlier you were spending lot of money to host your .NET applications for commercial use. Now you no need to worry Now Microsoft is providing you to host your application free on Popfly for web pages and also visual studio express projects.

    If you like this article, Please share with others

    Other Interested .NET Readings:
    Writing/Developing Facebook Applications in .NET using Facebook.NET SDK
    Refactor .NET code using Visual Studio and Refactor! Pro
    Dead-end for Microsoft ?
    .NET Obfuscation using Dotfuscator for Source Code Protection
    Windows System Tray Programming using C# and VB.NET
    Microsoft Office 2007 Features and Free Download
  • Evaluation of .Net Framework

    Send EMAIL through ASP.NET

    //SmtpMail.SmtpServer = "127.0.0.1"; SmtpMail.SmtpServer = ConfigurationSettings.AppSettings["SmtpServer"]; System.Web.Mail.MailMessage msgMail = new System.Web.Mail.MailMessage(); msgMail.From = txtFrom.Text.ToString(); msgMail.To = txtTo.Text; msgMail.Cc = txtC.Text; msgMail.Bcc = txtBcc.Text; msgMail.Subject = txtSubject.Text; msgMail.Body = txtMessage.Text; msgMail.Attachments.Add(new MailAttachment(txtAttachment.Text)); SmtpMail.Send(msgMail);

    Saturday, May 24, 2008

    Display confirmation when closing browser.

    Wednesday, May 14, 2008

    Sql Server Transactions - ADO.NET 2.0 - Commit and Rollback - Using Statement - IDisposable

    Here is the basic template for an ADO.NET 2.0 Transaction: using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = connection.CreateCommand(); SqlTransaction transaction = null; try { // BeginTransaction() Requires Open Connection connection.Open(); transaction = connection.BeginTransaction(); // Assign Transaction to Command command.Transaction = transaction; // Execute 1st Command command.CommandText = "Insert ..."; command.ExecuteNonQuery(); // Execute 2nd Command command.CommandText = "Update..."; command.ExecuteNonQuery(); transaction.Commit(); } catch { transaction.Rollback(); throw; } finally { connection.Close(); } } A c# using statement wraps up the connection, because SqlConnection implements IDisposable. The using statement makes sure that Dispose() gets called on the connection object so it can free up any unmanaged resources. Before you can begin a transaction, you must first open the connection. You begin your transaction and then assign any newly created command objects to that transaction and perform queries as necessary. Commit the transaction. If an error occurs, Rollback the transaction in a catch statement to void out any changes and then rethrow the error so that the application can deal with it accordingly. The connection is properly closed in the finally statement, which gets called no matter what, and any unmanaged resources are disposed when the using statement calls Dispose() on the connection. Pretty simple solution to a fairly advanced topic. The above template could actually implement a second c# using statement around command, because SqlCommand also implements IDisposable. I don't know that it is really necessary, however. More theoretical than probably anything. I just like to see using statements around anything that implements IDisposable: using (SqlConnection connection = new SqlConnection(connectionString)) { using (SqlCommand command = connection.CreateCommand()) { SqlTransaction transaction = null; try { // BeginTransaction() Requires Open Connection connection.Open(); transaction = connection.BeginTransaction(); // Assign Transaction to Command command.Transaction = transaction; // Execute 1st Command command.CommandText = "Insert ..."; command.ExecuteNonQuery(); // Execute 2nd Command command.CommandText = "Update..."; command.ExecuteNonQuery(); transaction.Commit(); } catch { transaction.Rollback(); throw; } finally { connection.Close(); } } }

    Wednesday, April 16, 2008

    Various LInks

    http://www.411asp.net http://www.aspnet.happycodings.com/index.html http://www.dreamincode.net http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&plcid=&pver=5.2&os=&over=&olcid=&clcid=&ar=Media&sba=Showcase&o1=&o2=&o3= http://www.codinghorror.com/blog/files/Visual%20Studio%20.NET%202005%20Keyboard%20Shortcuts.htm http://authors.aspalliance.com/aspxtreme/webforms/index.aspx http://www.w3schools.com/js/js_examples_3.asp http://www.dotnetbips.com/articles/e644e9a7-f1ec-41d1-ad19-5cda53b6e9cf.aspx http://aspnet.devdirect.com/All/PopupComponents_PCAT_2029.aspx http://aspalliance.com/1306_How_to_Show_MessengerLike_Popups_Using_AJAX.all http://swik.net/Ajax/del.icio.us%2Ftag%2Fajax/Developing+AJAX+based+popup+notifications/bk2c3 http://www.telerik.com/community/forums/allthreads/b312H-kh.aspx
    Web Events
    Visual Studio .NET 2005 Keyboard Shortcuts
    ASPXtreme Web WorkShop: ASP.NET Web Forms
    A workshop on .NET applications design and development. Step-by-step how-to pages help you learn skills and do specific tasks as you plan, build and manage your Web app, from start to finish.
    JavaScript Examples
    Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building.
    DotNetBips.com :: Blossom your .NET skills
    ASP.Net Popup Controls & Messenger Popup Components
    Enable your applications to display Messenger-style popup windows to notify users of an event or request attention.
    How to Show Messenger-Like Popups Using AJAX: ASP Alliance
    In this article Bilal examines how to build a simple database notifier that pops a messenger-like popup on an ASP.NET page whenever a new record is inserted into the database table using ASP.NET 2.0 AJAX 1.0 Extensions.
    Developing AJAX based popup notifications - SWiK
    DotNetBips.com :: The .NET Knowledge Base - ASP.NET, C#, VB.NET, Web Services, Windows Forms and many mroe topics in .NET
    Build ASP.NET, AJAX, and Windows Forms applications with confidence and ease
    Telerik is a leading vendor of ASP.NET and Windows Forms UI components, Content Management Systems (CMS), Reporting solutions, and add-ons for SharePoint. Telerik's name is associated not only with reliable and high-performance products, but also with meticulous technical support.
    DotNetBips.com :: Blossom your .NET skills
    Yahoo! India News- Top 10 Hotels in India
    Use Yahoo! India News to find breaking news, current events and the latest headlines and news photos & videos of top stories, world, business, entertainment, sports, technology, and more.
    Calendar Sample
    How to make a simple CSS dropdown menu | evolt.org
    A world community for web developers, evolt.org promotes the mutual free exchange of ideas, skills and experiences.
    Online Menu Design - Visual CSS QuickMenu
    .NET Interview Questions at Microsoft .NET Support
    What̢۪s a bubbled event? | walkin-interview.com
    When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can
    Kalptaru Infosoft Pvt Ltd - India - Other
    Kalptaru Infosoft Pvt Ltd exports to North America, South America, Eastern Europe, Southeast Asia, Africa, Oceania, Mid East, Eastern Asia, Western Europe, with products under category and more.
    Ahmedabad Software Companies - List of IT Companies in Ahmedabad, Gandhinagar
    List of Software & IT Companies in Ahmedabad/Gandhinagar, Gujarat, India
    Community : The Official Microsoft ASP.NET Site
    Microsoft portal site for the ASP.NET development community. Download Visual Web Developer, post to the forums, read ASP.net blogs and learn about ASP.net.
    Popup - Blog Toplist
    Articles about Popup by blogs
    JavaScript Regular Expressions patterns
    Click here to learn about regular expressions in JavaScript
    Dynamic Drive DHTML Scripts- Popup box
    Controlling your Modem with AT Commands
    Google
    Software Engineering Proverbs
    Stories about software engineering practices and lessons: Collected graffiti.
    webpart 1
    Microsoft ASP.NET QuickStarts Tutorial
    .NET Framework Assemblies
    Explains what are the .NET Framework assemblies and what are their benefits to make your programming tasks easier
    TopSurveys
    Make money from taking online surveys! You get paid for each survey, the longer the survey the more you get paid!
    YouTube - Learn VB .NET - Custom Shaped Forms - VBdotNET.m-sn.com
    http://vbdotnet.m-sn.com for 100s more video guides to vb.net
    Walkthrough: Creating a Web Site with Membership and User Login
    asp.net web templates
    This site offers hundreds of website templates, free web templates, web templates, and free website templates for individuals, professionals and small business owners
    Warez Releases - Full Warez Downloads Updated Every 5 Minutes!
    RapidShare: 1-Click Webhosting