Thursday, May 7, 2009

ASP.NET 1.1 vs 2.0

he latest version of ASP.NET, 2.0, is more than an upgrade—it is a major update of the technology, as it changes the way ASP.NET applications are designed, compiled, and deployed. Microsoft does recognize the existence of a large number of ASP.NET 1.1 installations, so 2.0 was designed to allow older applications to work without problems. On the other hand, the need to convert existing applications to the 2.0 platform may arise. With that said, let's examine the major differences between the versions, as well as areas that may be problems during the conversion process.Version changesWhile there are many changes between ASP.NET 1.1 and 2.0, there are certain ones that have a greater impact of
  • Code-behind model: ASP.NET 2.0 introduces the concept of partial classes, whereas a class can span multiple class files. It is a key feature used in Visual Studio 2005 to separate system-generated code from user code. This negates the scenario where you find yourself scrolling through source code and encountering the code generated by the system. The partial class approach reduces the risk of inadvertently editing system code and results in smaller code-behind files.
  • Directories: ASP.NET 2.0 has added a number of special directories where 1.1 had only the one required bin directory. Most of these new directories have the App_ prefix with names like App_Code, App_Data, App_GlobalResources, and App_LocalResources, while the bin directory still exists along with a themes directory. The new directories are a key aspect of 2.0's elimination of project files.
  • No more project files: Gone are the days of project files with ASP.NET and Visual Studio 2005. The project is now the complete Web project directory, which is a drastic shift from 1.1 and can cause migration issues as described later.
  • Compilation model: With 1.1, all code was compiled into one assembly placed in the bin directory. With 2.0, the assembly is separated into multiple assemblies. These multiple assemblies may be created on-the-fly or precompiled. Examples of multiple assemblies are one assembly for each ASP.NET directory like App_Code and App_Data as well as individual assemblies for Web Forms, User Controls, and so forth. This is a major shift in the application structure; it offers more deployment options in how the application is delivered to the users.
  • Application deployment: The deployment of 1.1 applications was fairly straightforward as you moved the content files along with the necessary assembly files—it could easily be accomplished with a simple copy and paste with limited options. The 2.0 model provides various options for deploying an application. For instance, you may choose to precompile all code and deploy it or go the other way with no precompilation. Also, you can lock down deployed content files so no changes may be made after deployment (this is a major difference from 1.1).

The list provides a high-level view of the main differences between ASP.NET 1.1 and 2.0 and what can affect the conversion of an existing application to 2.0. Now let's take a closer look at possible problem areas.

Friday, May 1, 2009

Remove extra spaces from string using regular expression, asp.net, c#

public string RemoveExtaSpaces(string text)

{

Regex regex = new Regex(@”\s{2,}”, Options);


text = regex.Replace(text.Trim(), ” “); //This line removes extra spaces and make space exactly one.

//To remove the space between the end of a word and a punctuation mark used in the text we will

//be using following line of code


regex=new Regex(@”\s(\!|\.|\?|\;|\,|\:)”); // “\s” whill check for space near all puntuation marks in side ( \!|\.|\?|\;|\,|\:)”); )

text = regex.Replace(text, “$1″);

return text;


}