• Wriju's BLOG

    C# 3.0 Enhancements: Lambda Expression

    • 0 Comments

    After a pretty long time I am again back to the Blog business. During these days I was busy preparing myself on C# 3.0 for our ISV Developers. I started giving demos to them and during my study I found a good number of exciting features which C# 3.0 offers in a nutshell. I will talk about them one by one. Let’s start with Lambda expression.

     

    Lambda Expressions are giving first class treatment to delegate and functions. When you are dealing with Lambda Expressions then you are surely dealing with Delegates.

     

    Let’s assume this example.

     

    //Array of integers

    List<int> arrInt =

    new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

     

    //Using Predicate we are finding the even numbers

    List<int> even1 =

    arrInt.FindAll(new Predicate<int>(EvenGetter));

     

    foreach(int i1 in even1)

        Console.WriteLine(i1);

     

    Console.ReadKey();

     

    This retrieves the even numbers from the collection. But you need another method

    static bool EvenGetter(int i)

    {

        return i % 2 == 0;

    }

     

     

    In C# 2.0 we have introduced little smarter way. You can add inline function using the keyword delegate. The code looks like,

     

    //Using delegate keyword, more smarter way

    List<int> even1 = arrInt.FindAll(delegate(int i2)

    { return i2 % 2 == 0; });

     

    This does not require any extra function in the application. But it is still painful.

     

    Lambda Expression helps us to write code like.

     

    //Using Lambda Expression

    List<int> even1 = arrInt.FindAll( x => x % 2 == 0);

     

    This approach is without using delegate but the way of implementation much clean. In this syntax x => x % 2 == 0 can be changed to (int x) => x % 2 == 0

     

    Namoskar!!!

  • Wriju's BLOG

    C# 3.0 Features: Automatic Property (Part 3)

    • 6 Comments

    I was about to write this entry in my blog which I found. Before that I got comment in my previous Blog on C# 3.0 Features: Automatic Property (Part 2). The same question came in my mind. What will happen if you try to create an automatic property just with get. The C# 3.0 compiler throws an error. If you try to write

     

    //Automatic Property

    public int CustID2

    {

        get;

    }

     

    The error looks like

     

    'ConsoleApplication1.Customer.CustID2.get' must declare a body because it is not marked abstract or extern. Automatically implemented properties must define both get and set accessors.

     

    To many it is very unfortunate because most often we may need to declare read-only property (commonly known as “getter” property). But we do have way to do this

     

    The same set of property can be declared as

     

    public int CustID2

    {

        get;

        private set;

    }

     

    This allows us to create the read-only property.

     

    Namoskar!!!

  • Wriju's BLOG

    C# 3.0 Features: Automatic Property (Part 2)

    • 4 Comments

    Thank you everyone for showing interest on my blog entry C# 3.0 Features: Automatic Property. Questions like, why this approach? What if there is any condition in property? Let me tell you, we have implemented the higher level of abstraction in C# 3.0. If you are simply creating a property (we often do) then the pain declaring the local variable and its value setting/getting are being taken care by the CLR. So internally CLR declares the property exactly like what we used to do earlier.

     

    Let’s say

     

    public class Customer

    {

        public Customer() { }

     

        //Conventional Way

        private int _XYZ;

        public int CustID2

        {

            get { return _XYZ; }

            set { _XYZ = value; }

        }

       

        //Automatic Property

        public int CustID

        {

            get;

            set;

        }               

    }

     

    For both the cases if you examine the assembly through IL DASM. You will get the following result (the red-boxed areas are for automatic property)

     

     

    If you have noticed for the property CustID (which is Automatic) it created a private variable k__AutomaticallyGeneratedPropertyField0 of type int32. This is the extra work CLR does for us.

     

    We do have backward compatibility with C# 3.0. That means all the code that you have written in previous version of C# will compile with no error (provided it is clean codeJ).

     

    Namoskar!!!

  • Wriju's BLOG

    C# 3.0 Features: Automatic Property

    • 15 Comments

    I am super excited with the Orcas March 2007 CTP release. I was doing the hands on with the C# and LINQ and as you know C# 3.0 comes with a lot of new things which increases the level of abstraction for the developer. We now write less and do more. As I often have mentioned in my previous entries and presentations with Microsoft Partner that now have think more on why not on how. I remember the day when I first learned the Property. I used to scratch my head on what to do with get or set. I probably started it now as we have snippet for property. Anyways in conventional way we declare property in a class like

     

    public class Customer

    {

        public Customer() { }

     

        private int _CustID;

     

        public int CustID

        {

            get { return _CustID; }

            set { _CustID = value; }

        }    

               

    }

     

    Now C# 3.0 suggests us not to invest so much. Rather than using property like

     

    private int _CustID;

     

    public int CustID

    {

        get { return _CustID; }

        set { _CustID = value; }

    }   

     

    We can declare property like

     

    public int CustID

    {

        get;

        set;

    }

     

    No more private variable or = or value etc required. This is Automatic property in C# 3.0.

     

     

    Namoskar!!!

  • Wriju's BLOG

    LINQ to SQL with real life ASP.NET Data Domain

    • 1 Comments

    We have talked a lot about LINQ and its power. One of the main reasons behind the LINQ design goal was to enable the unified query like syntax for any kind of structured data.

     

    There is hardly any ASP.NET application which does not deal with data. We can create layered ASP.NET Application using the LINQ power. Scott talked about this and has given a very nice walkthrough.

     

    Please visit

     

    Using LINQ with ASP.NET (Part 1)

    Using DLINQ with ASP.NET (Part 2 of my LINQ series)

     

    Namoskar!!!

     

     

  • Wriju's BLOG

    LINQ to SQL: Finding T-SQL Query

    • 1 Comments

    LINQ to SQL (aka DLinq) generates SQL queries for us at the back. SqlMetal.exe does not contain any SQL query as it is pure object we do not prefer to keep anything which is not strongly typed. As you all know that LINQ to SQL creates the query for us. But the question is how it looks like? If you really want to verify the performance to make sure that LINQ to SQL is giving us the best query performance (always pain to DB developer)

     

    Say, you have a small which retrieves the data from Northwind database. For more details please visit my entry on DLINQ: ADO.NET vNext a lap around

     

    Northwind db = new Northwind("northwindConnection");

     

    var query = from c in db.Customers

                where c.City == "London"

                select c;

     

    foreach (var c in query)

        Console.WriteLine(c.CompanyName);

     

    Very well it will return the values one by one. Then how is the query?

     

    Yes we do have a property to get the SQL query inside the SqlMetal.exe generated class file. The name of the property is Log. Let’s see how we can implement it. I am using Console application. The code will look like

     

    db.Log = Console.Out;

     

    This will give you the SQL query in output window and the query would look like,

     

    SELECT [t0].[CustomerID], [t0].[CompanyName], [t0].[ContactName], ...

    FROM [Customers] AS [t0]

    WHERE [t0].[City] = @p0

    -- @p0: Input NVarChar (Size = 6; Prec = 0; Scale = 0) NOT NULL [London]

    SqlProvider\AttributedMetaModel

     

    Hope this will help you to rectify more confusion.

     

    Namoskar!!!

  • Wriju's BLOG

    IE 7: More Shortcut Keys

    • 0 Comments

    Few days back I have talked about the IE 7 short cut keys in one of my BLOG entries at IE 7 Shortcut keys tips. I also have found a page at IE 7 in Microsoft which talks about the exhaustive list on the same. Let me share that with you here

     

    http://www.microsoft.com/windows/products/winfamily/ie/quickref.mspx

     

    Namoskar!!!

  • Wriju's BLOG

    IM – An initiative from MSN

    • 0 Comments

    If you are Windows Live™ Messenger 8.1 user then you can be the part of this initiative.

     

    Where is Windows Live™ Messenger 8.1?

    Download is available from MSN.

     

     

    What is IM?

     

    (as mentioned in the site)

    i’m is a new initiative from Windows Live™ Messenger. Every time you start a conversation using i’m, Microsoft shares a portion of the program's advertising revenue with some of the world's most effective organizations dedicated to social causes. We've set no cap on the amount we'll donate to each organization. The sky's the limit.

     

    So any time you have an i’m™ conversation using Windows Live Messenger, you help address the issues you feel most passionate about, including poverty, child protection, disease, and environmental degradation. It's simple. All you have to do is join and start an instant messaging conversation. We'll handle the donation.

    There's no charge, so join now and put our money where your mouth is.

     

    Stay connected.

     

    Namoskar

  • Wriju's BLOG

    IE 7 Shortcut keys tips

    • 10 Comments

    We have started enjoying the IE7 and IE 7 always tries to help us by providing the possible shortcut keys (as being impatient we miss it). Here are those for you and me

     

    Keyboard shortcuts

    Open links in a new tab in the background

    CTRL+click

    Open links in a new tab in the foreground

    CTRL+SHIFT+click

    Open a new tab in the foreground

    CTRL+T

    Open a new tab from the Address bar

    ALT+ENTER

    Open a new tab from the search box

    ALT+ENTER

    Open Quick Tabs (thumbnail view)

    CTRL+Q

    Switch between tabs

    CTRL+TAB/CTRL+SHIFT+TAB

    Switch to a specific tab number

    CTRL+n (n can be 1-8)

    Switch to the last tab

    CTRL+9

    Close current tab

    CTRL+W

    Close all tabs

    ALT+F4

    Close other tabs

    CTRL+ALT+F4

    Mouse shortcuts

    Open a link in a background tab

    Click the middle mouse button on a link

    Open a new tab

    Double-click the empty space to the right of the last tab

    Close a tab

    Click the middle mouse button on the tab

     

    Namoskar!!!

  • Wriju's BLOG

    What’s new in Microsoft Pre-release Software Visual Studio Code Name "Orcas" - March 2007 Community Technology Preview (CTP)

    • 3 Comments

    There are a lot. Best place to view the enhancements is non none other than its own download location at MSDN.

     

    Namoskar!!!

     

  • Wriju's BLOG

    Orcas March 2007 CTP VPC and its Base Image

    • 6 Comments

    We have released the VPC of Orcas March 2007 CTP to avoid the conflict in production machine. Since the Virtual PC 2004 SP1 is free and now downloadable from MSDN. One very important thing is that you should not miss to download the Orcas Base Image. If you miss to download this you will end up loosing the valuable experience with the magic of Orcas.

     

    Namoskar!!!

  • Wriju's BLOG

    ASP.NET 2.0 AJAX Extensions (aka Atlas) Video Tutorials

    • 1 Comments

    Get Started with ASP.NET AJAX

    Take your first steps toward learning Microsoft ASP.NET AJAX, from downloading and installing the framework to creating your first AJAX-style application.

    Get Started with the ASP.NET AJAX Control Toolkit

    Learn how to extend your ASP.NET AJAX applications using the ASP.NET AJAX Control Toolkit. This video starts with the very basics, including downloading and installing the toolkit, and adding a few...

    Use the ASP.NET AJAX CascadingDropDown Control Extender

    This video demonstrates how ASP.NET’s standard DropDownList can become AJAX-enabled using the CascadingDropDown control extender from the ASP.NET AJAX Control Toolkit. You will also see how...

    Implement Dynamic Partial-Page Updates with ASP.NET AJAX

    In this video you will learn how to add dynamic partial-page updates to your ASP.NET application using Microsoft ASP.NET AJAX. In particular, you will see how to use the TimerControl to manage...

    Make Client-Side Network Callbacks with ASP.NET AJAX

    In this video we see how Microsoft ASP.NET AJAX helps web developers make network callbacks directly from client-side script code. We see also how an ASP.NET AJAX-enabled web service generates the...

    Add ASP.NET AJAX Features to an Existing Web Application

    Learn how easily you add Microsoft ASP.NET AJAX functionality to an existing ASP.NET application. This video shows that there is no need to change your server controls or data access code —...

    ASP.NET AJAX Enable an Existing Web Service

    This video demonstrates how simple it is to add Microsoft ASP.NET AJAX functionality to an existing ASP.NET web service. This enables the web service to generate a JavaScript proxy that the client...

    Use the ASP.NET AJAX TextBoxWatermark Control Extender

    In this video you will learn how to use the TextBoxWatermark control extender from the ASP.NET AJAX Control Toolkit, which adds new watermark properties to all standard TextBox controls on an ASP.NET...

    Use the ASP.NET AJAX Popup Control Extender

    This video demonstrates the use of the Popup control extender that ships with the ASP.NET AJAX Control Toolkit. Learn how to extend a TextBox control so that, when it receives focus, a popup dialog...

    Use the ASP.NET AJAX ModalPopup Extender Control

    Learn how to use the ASP.NET AJAX ModalPopup extender control that comes with the ASP.NET AJAX Control Toolkit. In this video the ModalPopup extender is used to pop open a standard ASP.NET Panel...

    Use the ASP.NET AJAX AlwaysVisible Control Extender

    See how easy it is to anchor a page element to a position on screen, where it remains always visible no matter how far the user may scroll the document. The floating page element may be anything...

    Use the ASP.NET AJAX Accordion Control

    Learn how the ASP.NET AJAX Accordion control makes efficient use of screen real-estate by enabling the smooth animated transition between different content panes.

    Use the ASP.NET AJAX Client Library Controls

    Demonstrates the client-side programming experience using scripts and controls from the ASP.NET AJAX client library. The client controls add actions, behaviors, and data-bindings to the client-side...

    Use the ASP.NET AJAX Collapsable Panel Extender

    In this video you will learn how to use the ASP.NET AJAX Collapsable Panel Extender to allow the user to dynamically show or hide content on a web page.

    Use the ASP.NET AJAX Draggable Panel Extender

    With the ASP.NET AJAX Draggable Panel Extender you can provide a content panel with a header area that allows the user to move the panel around the web page.

    Use the ASP.NET AJAX DynamicPopulate Extender

    Watch a demonstration of using the ASP.NET AJAX DynamicPopulate extender to dynamically populate an area of a web page with the results of an asynchronous call to a web method.

    Use the ASP.NET AJAX FilteredTextbox Extender

    Learn how the handy ASP.NET AJAX FilteredTextbox extender allows the developer to define which characters the user may enter in a text box control.

    Use the ASP.NET AJAX HoverMenu Extender

    Discover how to use the HoverMenu extender control to create a context-sensitive menu that appears whenever the user hovers the mouse over an element of a web page.

    Use the ASP.NET AJAX ToggleButton Extender

    Demonstrates using the ToggleButton extender control to modify the behavior and appearance of the standard ASP.NET CheckBox control to enhance the user interface.

    Use an ASP.NET AJAX ScriptManagerProxy

    Learn how a ScriptManagerProxy enables a content page to pass references to the ScriptManager placed on its ASP.NET master page, allowing each content page to define its own AJAX behavior.

    Use the ASP.NET AJAX DropShadow Extender

    Discover how to improve the presentation of ASP.NET sites by using the AJAX DropShadow extender control to add opaque, rounded-corner drop shadows to areas of your pages.

    Use the ASP.NET AJAX PasswordStrength Extender

    Learn how the PasswordStrength extender control provides immediate and dynamic feedback to users about the strength of their chosen passwords. The feedback can be a text notice, a graphical bar...

    Use the ASP.NET AJAX RoundedCorners Extender

    In this video we see how the RoundedCorner extender control can give your web pages a softer look and feel by adding attractive round corners to content areas.

    Use the ASP.NET AJAX Timer Control

    The AJAX Timer control enables a portion of an ASP.NET web page to be dynamically updated at a regular interval, rather than needing the user to perform an action such as clicking on a...

    Implement the Predictive Fetch Pattern for AJAX

    Demonstrates an implementation of the Predictive Fetch pattern for AJAX, where the AJAX engine uses the current state of the user’s interaction to predict which set of content will be...

    Namoskar!!!

     

  • Wriju's BLOG

    Sandcastle March 2007 CTP is Available

    • 0 Comments

     

    What is Sandcastle?

    Sandcastle documentation compilers enable managed class library developers throughout the world to easily create accurate, informative documentation with a common look and feel.

     

    From where to download?

     

    http://www.microsoft.com/downloads/details.aspx?FamilyID=e82ea71d-da89-42ee-a715-696e3a4873b2&displaylang=en

     

    What’s is there?

     

    http://blogs.msdn.com/sandcastle/archive/2007/03/06/announcing-march-2007-sandcastle-ctp.aspx

     

    Other related resources

     

     

    Enjoy

     

    [Dedicated to Tupur on the eve of International Women’s Day. Wish you a very best of luck.]

     

    Namoskar!!!

     

  • Wriju's BLOG

    BLinq: Wow and w’s there

    • 0 Comments

     

    BLinq is Linq integration to ASP.NET Applications which is now available in official ASP.NET website at http://www.asp.net/sandbox/app_blinq.aspx?tabid=62. You can download and install the exe to work with BLinq. BLinq is named keeping in mind that the web world is captured by blog sites and Linq is the core mapping technology behind it.

     

    If you face any issue the use the BLinq forum at http://forums.asp.net/1076/ShowForum.aspx

     

    Download is available at http://download.microsoft.com/download/1/B/0/1B02E2C5-2F4D-4F28-803B-8EF038FC0406/BlinqSetup.msi.

     

    Before downloading you can check the prerequisites to enjoy the feature. The forum queries and feedback are being addressed by Polita Paulus who created this tool. So you can expect positive response from the forum. Before starting you can watch the 17 minute video from http://www.asp.net/learn/videos/view.aspx?tabid=63&id=35. This is a really interesting video by the creator of BLinq.

     

    Here is a small example on the BLinq switches

     

    From command browse the folder C:\Program Files\Microsoft ASP.NET\Blinq

     

    Then in the command prompt type

     

    blinq /server:myServer\myInstance /database:Northwind /namespace:MyBlinq

    /vDir:MyBlinqVD /t:c:\MyBlinqD /user:dbCracker /password:secret!

     

    Lot more other switches are available. This will create a virtual directory with the name MyBlinqVD from the existing folder at c:\MyBlinqD from the Northwind database at myServer’s myInstance using the user credential dbCracker\secret!

     

    Let’s explore more and give feedback to developer directly.

     

    [I am dedicating this article to one of my friends new born baby “Sricharan”]

     

    Namoskar!!!

     

  • Wriju's BLOG

    Orcas March 2007 CTP Error: Unable to find the requested .Net Framework Data Provider. It may not be installed.

    • 14 Comments

     

    If you have installed Orcas March 2007 CTP and trying to play with SQL Server 2005 Express database using the IDE feature. You might meet with an error mentioning “Unable to find the requested .Net Framework Data Provider.  It may not be installed.” while trying the below mentioned steps

     

    In Server Explorer, Add New Connection - > Choose SQL Server 2 - > Provide the local database server information -> (drop down will not be refreshed or if you forcefully type the database name in the text box) and hit OK button. The above mentioned error will block you to go ahead.

     

    I did install Orcas in fresh machine and then installed VS 2005 there. I think that was the issue. But the workaround is little tricky here,

     

    Steps to follow:

     

    Go to the folder C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG

    Select the Machine.config and then find the tag <DbProviderFactories> under <system.data>.Then next step is to hide all the provider entries which has either Version=3.5.0.0 or Version=9.0.242.0.

     

    Following are the entries in my machine

    <DbProviderFactories>

          <add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

     

          <add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

     

          <add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

     

          <add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

     

          <!--<add name="SQL Server Compact Edition Data Provider" invariant="System.Data.SqlServerCe" description=".NET Framework Data Provider for Microsoft SQL Server Compact Edition" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />

     

          <add name="SQL Server Compact Edition Client Data Provider" invariant="Microsoft.SqlServerCe.Client" description=".NET Framework Data Provider for Microsoft SQL Server Compact Edition Client" type="Microsoft.SqlServerCe.Client.SqlCeClientFactory, Microsoft.SqlServerCe.Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />

          <add name="SQL Server CE Data Provider" invariant="Microsoft.SqlServerCe.Client" description=".NET Framework Data Provider for Microsoft SQL Server 2005 Mobile Edition" type="Microsoft.SqlServerCe.Client.SqlCeClientFactory, Microsoft.SqlServerCe.Client, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />-->

     

        </DbProviderFactories>

     

    Then you are ready to work. Everything else will work fine.

     

    Thanks to the entry from where I got the clue to the solution. You could find the bug entry at connect.

     

    Namoskar!!!

  • Wriju's BLOG

    Patterns and Practices: How-Tos

    • 1 Comments

     

    ASP.NET 1.1

    ·         How To: Create a Custom Account to Run ASP.NET

    ·         How To: Create a DPAPI Library

    ·         How To: Create an Encryption Library

    ·         How To: Create GenericPrincipal Objects with Forms Authentication

    ·         How To: Implement IPrincipal

    ·         How To: Implement Kerberos Delegation for Windows 2000

    ·         How To: Prevent Cross-Site Scripting in ASP.NET

    ·         How To: Set Up SSL on a Web Server

    ·         How To: Set Up Client Certificates

    ·         How To: Store an Encrypted Connection String in the Registry

    ·         How To: Use DPAPI (Machine Store) from ASP.NET

    ·         How To: Use DPAPI (User Store) from ASP.NET with Enterprise Services

    ·         How To: Use Forms Authentication with Active Directory

    ·         How To: Use Forms Authentication with SQL Server 2000

    ·         How To: Use the Network Service Account to Access Resources in ASP.NET

    ·         How To: Use Regular Expressions to Constrain Input in ASP.NET

    ·         How To: Use Role-based Security with Enterprise Services

    ASP.NET 2.0

    ·         How To: Configure the Machine Key in ASP.NET 2.0

    ·         How To: Connect to SQL Server Using SQL Authentication in ASP.NET 2.0

    ·         How To: Connect to SQL Server Using Windows Authentication in ASP.NET 2.0

    ·         How To: Create a Service Account for an ASP.NET 2.0 Application

    ·         How To: Encrypt Configuration Sections in ASP.NET 2.0 Using DPAPI

    ·         How To: Encrypt Configuration Sections in ASP.NET 2.0 Using RSA

    ·         How To: Instrument ASP.NET 2.0 Applications for Security

    ·         How To: Improve Security When Hosting Multiple Applications in ASP.NET 2.0

    ·         How To: Perform a Security Deployment Review for ASP.NET 2.0

    ·         How To: Prevent Cross-Site Scripting in ASP.NET

    ·         How To: Protect Forms Authentication in ASP.NET 2.0

    ·         How To: Protect From SQL Injection in ASP.NET

    ·         How To: Use ADAM for Roles in ASP.NET 2.0

    ·         How To: Use Authorization Manager (AzMan) with ASP.NET 2.0

    ·         How To: Use Code Access Security in ASP.NET 2.0

    ·         How To: Use Forms Authentication with Active Directory in ASP.NET 2.0

    ·         How To: Use Forms Authentication with Active Directory in Multiple Domains in ASP.NET 2.0

    ·         How To: Use Forms Authentication with SQL Server in ASP.NET 2.0

    ·         How To: Use Health Monitoring in ASP.NET 2.0

    ·         How To: Use Impersonation and Delegation in ASP.NET 2.0

    ·         How To: Use Medium Trust in ASP.NET 2.0

    ·         How To: Use Membership in ASP.NET 2.0

    ·         How To: Use the Network Service Account to Access Resources in ASP.NET

    ·         How To: Use Protocol Transition and Constrained Delegation in ASP.NET 2.0

    ·         How To: Use Regular Expressions to Constrain Input in ASP.NET

    ·         How To: Use Role Manager in ASP.NET 2.0

    ·         How To: Use Windows Authentication in ASP.NET 2.0

    Authentication and Authorization

    ·         How To: Connect to SQL Server Using SQL Authentication in ASP.NET 2.0

    ·         How To: Connect to SQL Server Using Windows Authentication in ASP.NET 2.0

    ·         How To: Create GenericPrincipal Objects with Forms Authentication

    ·         How To: Protect Forms Authentication in ASP.NET 2.0

    ·         How To: Use Authorization Manager (AzMan) with ASP.NET 2.0

    ·         How To: Use Forms Authentication with Active Directory

    ·         How To: Use Forms Authentication with Active Directory in ASP.NET 2.0

    ·         How To: Use Forms Authentication with Active Directory in Multiple Domains in ASP.NET 2.0

    ·         How To: Use Forms Authentication with SQL Server 2000

    ·         How To: Use Forms Authentication with SQL Server in ASP.NET 2.0

    ·         How To: Use Windows Authentication in ASP.NET 2.0

    Code Access Security

    ·         How To: Create a Custom Encryption Permission

    ·         How To: Use Code Access Security in ASP.NET 2.0

    ·         How To: Use Code Access Security Policy to Constrain an Assembly

    Code Review

    ·         How To: Perform a Security Code Review for Managed Code (Baseline Activity)

    Communications Security

    ·         How To: Call a Web Service Using Client Certificates from ASP.NET

    ·         How To: Call a Web Service Using SSL

    ·         How To: Set Up SSL on a Web Server

    ·         How To: Set Up Client Certificates

    ·         How To: Use IPSec for Filtering Ports and Authentication

    ·         How To: Use IPSec to Provide Secure Communication Between Two Servers

    ·         How To: Use SSL to Secure Communication with SQL Server 2000

    Configuration

    ·         How To: Create a Custom Account To Run ASP.NET

    ·         How To: Encrypt Configuration Sections in ASP.NET 2.0 Using DPAPI

    ·         How To: Encrypt Configuration Sections in ASP.NET 2.0 Using RSA

    Cryptography

    ·         How To: Create a DPAPI Library

    ·         How To: Create an Encryption Library

    ·         How To: Store an Encrypted Connection String in the Registry

    ·         How To: Use DPAPI (Machine Store) from ASP.NET

    ·         How To: Use DPAPI (User Store) from ASP.NET with Enterprise Services

    Deployment Review

    ·         How To: Perform a Security Deployment Review for ASP.NET 2.0

    Enterprise Services (.NET Framework 1.1)

    ·         How To: Use Role-based Security with Enterprise Services

    Impersonation and Delegation

    ·         How To: Implement Kerberos Delegation for Windows 2000

    ·         How To: Use Impersonation and Delegation in ASP.NET 2.0

    Input and Data Validation

    ·         How To: Prevent Cross-Site Scripting in ASP.NET

    ·         How To: Protect From SQL Injection in ASP.NET

    ·         How To: Use Regular Expressions to Constrain Input in ASP.NET

    Patching and Updating

    ·         How To: Secure Your Developer Workstation

    ·         How To: Implement Patch Management

    SQL Server 2000

    ·         How To: Connect to SQL Server Using SQL Authentication in ASP.NET 2.0

    ·         How To: Connect to SQL Server Using Windows Authentication in ASP.NET 2.0

    ·         How To: Protect From SQL Injection in ASP.NET

    ·         How To: Use Forms Authentication with SQL Server in ASP.NET 2.0

    ·         How To: Use SSL to Secure Communication with SQL Server 2000

    Threat Modeling

    ·         How To: Create a Threat Model for a Web Application at Design Time

    Web Services (.NET Framework 1.1)

    ·         How To: Call a Web Service Using Client Certificates from ASP.NET

    ·         How To: Call a Web Service Using SSL

    Namoskar

  • Wriju's BLOG

    Orcas March 2007 CTP is now available

    • 0 Comments

     

    Wow we have it here

     

    For the features please visit the download page.  

     

    Namoskar

     

  • Wriju's BLOG

    LINQ Resources

    • 0 Comments

     

    Let us compile the resources on LINQ Project and its components. To work with LINQ there are two options available for you. One is to install the Orcas CTP from MSDN and the other is with the Visual Studio 2005 install the LINQ May 2006 CTP. I would prefer to use the second option. Mainly because we are working on Orcas and few features that are available with LINQ May CTP are not available in Orcas January CTP.

     

    Download Microsoft Visual Studio Code Name “Orcas” Language-Integrated Query, May 2006 Community Technology Preview and install on top of Visual Studio 2005. This will have the compiler support for C# 3.0 / VB 9.0 language enhancements along with IntelliSense support.

     

    Once you have it in your machine you would be able to see the templates in File > New Project > C# > LINQ Preview which will contain

    Ø       LINQ Console Applications

    Ø       LINQ Windows Applications

    …..

     

     

    LINQ Project has multiple components like,

    Ø       LINQ to Object (formerly known as LINQ)

    Ø       LINQ to SQL (formerly known as DLinq)

    Ø       LINQ to XML (formerly known as XLinq)

     

    MSDN Articles

    Ø       LINQ FAQ

    Ø       C# 3.0 Language Specification

    Ø       C# 3.0 Language Enhancements Chat

    Ø       The LINQ Project

    Ø       LINQ Project Overview

    Ø       Standard Query Operators

    Ø       DLinq Overview for C# Developers

    Ø       LINQ to Entities

    Ø       DLinq Designer

    Ø       XLinq Overview

    Ø       LINQ Over DataSet for C# Developers

     

    LINQ to Object (LINQ) Resources

    +++++++++++++++++

    We have 101 LINQ Samples on LINQ to Object which I think will give you clearer picture on its capability.

     

    Once you have installed the LINQ Project in your PC you will find Hands-on Lab and samples in the installed folder (e.g., C:\Program Files\LINQ Preview). So please go ahead and explore them.

     

    LINQ to SQL (DLinq) Resources

    ++++++++++++++++++++

     

    There is a nice walkthrough available at MSDN. Please download the instruction from DLinq Designer for VB and C#

     

    For lap-around with the SqlMetal.exe (the command line tool equivalent to DLinq Designer) for LINQ to SQL (DLinq), I have added an entry in my blog titled DLinq: ADO.NET vNext a lap around.

     

    LINQ to XML (XLinq) Resources

    ++++++++++++++++++++

    LINQ to XML is not the replacement to System.Xml namespace. It is smarter and quicker way to handle XML from .NET. LINQ to XML is element centric and consumes less memory. The object starts with “X” not “Xml”. For example in LINQ to XML it is XElement not XmlElement (as for System.Xml).

     

    I have added in my blog entries for LINQ to XML.

     

    Ø       XLinq: Beginners Walkthrough

    Ø       XLinq: Create XML from object using LINQ

     

    Added resources

     

    LINQ on Channel9

    Watch this Channel9 video with Anders Hejlsberg and Luca Bolognese as they explain what The LINQ Project is, and how it will help you create XML and data-driven applications.   

     

    More LINQ on Channel9

    Anders Hejlsberg and Sam Drucker discuss LINQ and LINQ to Entities.

     

    Namoskar

     

  • Wriju's BLOG

    XLinq: Create XML from object using LINQ

    • 4 Comments

     

    We have seen how to create the XML content from raw data initializing elements and attributes one by one. More realistic approach in the world of application development would be to read the values either from relational database or collection. Let’s use the combined power of LINQ and XLinq to create XML content easily and smartly.

     

    Using C# 3.0 enhancement, implicitly typed array which is the combination of anonymous object initializers to create the anonymously typed data structures.

    My famous Customers object, defined 

     

    var objCust = new[]

    {

     new {CustID = 2, CustName = "Sumitra", Phone = "123-123-1236"},

     new {CustID = 3, CustName = "Wriju", Phone = "123-123-1235"},

     new {CustID = 4, CustName = "Writam", Phone = "123-123-1234"},

     new {CustID = 1, CustName = "Debajyoti", Phone = "123-123-1237"}   

    };

     

    Now we will create XML out of it with proper order (notice that the CustID is not in proper sequence). We can filter the data with the help of LINQ.

     

    XElement _customers = new XElement("customers",

                            from c in objCust

                            orderby c.CustID //descending 

                            select new XElement("customer",

                                new XElement("name", c.CustName),

                                new XAttribute("ID", c.CustID),

                                new XElement("phone", c.Phone)

                                                )

                                        );

     

    Console.WriteLine(_customers);

     

    The output will look like.

     

    <customers>

      <customer ID="1">

        <name>Debajyoti</name>

        <phone>123-123-1237</phone>

      </customer>

      <customer ID="2">

        <name>Sumitra</name>

        <phone>123-123-1236</phone>

      </customer>

      <customer ID="3">

        <name>Wriju</name>

        <phone>123-123-1235</phone>

      </customer>

      <customer ID="4">

        <name>Writam</name>

        <phone>123-123-1234</phone>

      </customer>

    </customers>

     

    Isn’t it cool!!!! Yes, yes, yes….

     

    Namoskar

     

  • Wriju's BLOG

    XLinq: Beginners Walkthrough

    • 6 Comments

     

    Let’s play with Linq to XML (aka XLinq). XLinq is different from conventional .NET way to work with XML. Linq to XML is not the replacement it is smarter and superior way to work with XML with Language-INtegrated Query.

     

    Let’s suppose you need to create XML content like

     

    <employees>

      <employee age="28">

        <name>Wriju</name>

        <email>wriju@abc.com</email>

      </employee>

      <employee age="18">

        <name>Writam</name>

        <email>writam@abc.com</email>

      </employee>

    </employees>

     

    using the power of XLinq. If you notice my code here you will find the name of objects under XLinq library start with “X” instead of Xml.

     

    Here we go

     

    XElement _xml = new XElement("employees",

                        new XElement("employee",

                            new XElement("name", "Wriju"),

                            new XAttribute("age", "28"),

                            new XElement("email", "wriju@abc.com")

                    ),

                        new XElement("employee",

                            new XElement("name", "Writam"),

                            new XAttribute("age", "18"),

                            new XElement("email", "writam@abc.com")

                        )

                    );

     

    Console.WriteLine(_xml);

     

    You can also save the content in proper XML format rather than just showing them in string.

     

    _xml.Save(@"C:\MyXMLData.xml");

     

    Now this XML has couple of things missing like <?xml version="1.0" encoding="utf-8"?>

     

    To add this you need to create XDocument instead of XElement.

     

    The code will look like

     

    XDocument _doc = new XDocument(

        new XDeclaration("1.0", "utf-8", "yes"),

        new XComment("Sample XML"),

        new XElement("employees",

                        new XElement("employee",

                            new XElement("name", "Wriju"),

                            new XAttribute("age", "28"),

                            new XElement("email", "wriju@abc.com")

                    ),

                        new XElement("employee",

                            new XElement("name", "Writam"),

                            new XAttribute("age", "18"),

                            new XElement("email", "writam@abc.com")

                        )

                    )

    );

     

    To just display the data use

     

    Console.WriteLine(_doc);

     

    To save use,

    _doc.Save(@"C:\MyXML.xml");

     

    Happy weekend!!!

     

    Namoskar

     

  • Wriju's BLOG

    LINQ in not only for Object Query

    • 1 Comments

     

    Hello all,

     

    Here we will explore another side of LINQ (Language-INtegrated Query). We all know that LINQ is to query the object (even to the System object). Using the System.Reflection namespace we can get the list of Methods, Fields etc using LINQ Query (with the filter and sort). Lets see one small example on that,

     

    IEnumerable<Type> all = from t in typeof(SqlConnection).Assembly.GetTypes()

                            where t.Name == "SqlConnection"                                   

                            orderby t.Name

                            select t;

     

    foreach(var v in all)

    {

        textBox1.Text += "Start:Methods of " +  v.Name   + "\r\n";

        textBox1.Text += "===================================\r\n";

        foreach(MemberInfo mi in v.GetMembers())

            textBox1.Text += mi.Name   + "\r\n";

    }

     

    The output will display the list of methods from the SqlConnection class.

     

    Namoskar

     

  • Wriju's BLOG

    ‘System.Data.TypedTableBaseExtensions.Where<T>(System.Data.TypedTableBase<T>, System.Query.Func<T,bool>)' cannot be inferred from the usage. Try specifying the type arguments explicitly

    • 0 Comments

     

    This is first time I am writing a BLOG post with an error messageJ. This error message you will experience while writing code in Orcas Jan CTP. There is no LINQ Windows or LINQ Console Application template available. So no references/namespace directives will be added automatically. If you have installed Orcas Jan CTP and are trying to create LINQ Apps there and follow the Charlie’s BLOG, you need to manually add couple of dlls from \Windows\Microsoft.NET\Framework\v3.5.XXXXX\ (I have version 3.5.11209 ie. Microsoft .NET Framework 3.5 (GreenBits)). Dlls are System.Core.dll, System.Data.Linq.dll, System.Xml.Linq.dll and add a reference “System.Query”. But still that will throw you and error for the simple code

     

    int[] nums = {1,2,3,4,5,6,7};

     

    var q = from n in nums

            where n>5

            select n;

     

    There where will throw you and error with the following message

    ‘System.Data.TypedTableBaseExtensions.Where<T>(System.Data.TypedTableBase<T>, System.Query.Func<T,bool>)' cannot be inferred from the usage. Try specifying the type arguments explicitly

     

    Simple solution is that you need to add a line at the top of your page using System.Query; 

     

    Hope this will solve your problem.

     

    Namoskar

     

  • Wriju's BLOG

    LINQ Changes in January CTP (aka December CTP)

    • 0 Comments

     

    There are some changes happened with LINQ Project with the January CTP. The namespace names like System.Xml.XLinq or System.Query are no more there. Namespaces got changed to System.Data.Linq and System.Xml.Linq.

     

    Other than namespace and api changes lot of .proj file and C# syntax changes have happened.

     

    For detailed information visit Charlie’s BLOG

     

    Namoskar

     

  • Wriju's BLOG

    DLinq: ADO.NET vNext a lap around

    • 1 Comments

     

    Today I would like to discuss on the DLinq the natural roadmap to ADO.NET vNext. Little walkthrough, I am going to explore here which I enjoyed a lot during my hands on.

     

    Create LINQ Console application from your Visual Studio 2005.

     

    Go to LINQ installation folder e.g., C:\Program Files\LINQ Preview\Bin. There you will find one exe with the name SqlMetal. Type /? to get the help information on all possible options. I am assuming that you have SQL Server 2000 Northwind database installed in your application.

     

    Open Visual Studio 2005 Command prompt and type

     

    /server:myServer\myDBInstance /database:Northwind /code:MyNorthwind.cs /language:csharp /namespace:MyProject /pluralize

     

    This will create the MyNorthwind.cs code file in the folder from where executing. Next step would be to add that file to your LINQ Console application. Now your business layer is ready within even less that few seconds. Amazing!!!! “Thanks LINQ, thank you very much”, so you start watching your best TV show or read books go out because the SqlMetal has written 1200 lines of code for you. How much more luxury you want from life? It is beyond expectations.

     

    Now inside your code under static void Main(string[] args)

     

    Wish 0:

    Let us have a little background on ObjectDumper.dll which comes with LINQ Project installation. This returns all IEnumerable<T> in fairly easy way. You do not need a foreach statement to iterate through the collection to print the output. And if you use Anonymous type, displaying the output is as easy as Printf in C days. This dll is being created some awesome power of Reflection. The installation folder contains the sample which has got the source code for this static class. Moreover you can easily decide the depth you iterate through. My demonstration will tell you how.

     

    Wish 0+1:

    The common task for all wish list is that you have to tell your business logic which database this will connect.

    Northwind n = new Northwind

    (@"Data Source=myServer\SQL2000;Initial Catalog=Northwind;Integrated Security=True");           

     

    //Get the customers

    Table<Customer> customers = n.GetTable<Customer>();

     

    Wish 1:

    As you know SQL Server 2000 Northwind database has a table named Customer. Get all the customer first

     

    var t = from c in customers

            select c.CompanyName;

    foreach(var t1 in t)

    {

        Console.WriteLine(t1);

    }

     

    This will pullout all the Company name field from customers table.

     

    Wish 2:

    Now you want to implement some filter there.

    var t = from c in customers

            where c.City == "London"

            select c.CompanyName;

     

     

    Wish 3:

    Get two fields from there. Create a class and the property of each field, then initialize that class. Be little smart and use Anonymous types. Where CRL will create the class at runtime and will return it as typed collection (generics). This ensures the typed safety and the simplicity in terms of coding. If you have to declare class and related properties every time you want to get different set of results is not a very feasible solution. Friends we are here.

     

    //Anonymous

    var t = from c in customers

            where c.City == "London"

            select new{c.CompanyName, c.ContactName};

     

    //using foreach

    foreach(var t1 in t)

    {

    //Output: {CompanyName=Around the Horn, ContactName=Thomas Hardy}

        Console.WriteLine(t1);

     

        //Output: Around the Horn : Thomas Hardy

        Console.WriteLine(t1.CompanyName + " : " + t1.ContactName);

    }

     

    //using ObjectDumper

    //Output: CompanyName=Around the Horn  ContactName=Thomas Hardy

    ObjectDumper.Write(t);

     

    Wish 4:

    Let us join between customer and their orders.

    //Join between Cutomers and Orders

    var t = from c in customers 

            from o in c.Orders

            where c.City == "London"

            select new {c.CompanyName, o.OrderDate};

     

    ObjectDumper.Write(t);

    //Output:

    /*

    CompanyName=Around the Horn     OrderDate=11/15/1996

    CompanyName=Around the Horn     OrderDate=11/15/1996

    CompanyName=Around the Horn     OrderDate=12/16/1996

    CompanyName=Around the Horn     OrderDate=2/21/1997

    CompanyName=Around the Horn     OrderDate=6/4/1997

     */

     

    Wish 5:

    Now apply filer in orders too.

     

    var t = from c in customers 

            where c.City == "London"

            select new {

                        c.CompanyName,

                        Orders =                            

                            from o in c.Orders 

                            where o.ShipCity == "London"

                            select new {o.OrderDate, o.ShipCity}

                        };

     

    ObjectDumper.Write(t);

    //Output:

    //CompanyName=Around the Horn     Orders=...

    //CompanyName=B's Beverages       Orders=...

     

    Since this has one level deep iteration for orders. We can now use the power of ObjectDumper to easily get the results will small modification.

     

    ObjectDumper.Write(t,1);

    //Output:

    //CompanyName=Around the Horn     Orders=...

    //CompanyName=B's Beverages       Orders=...

    //  Orders: OrderDate=8/26/1996     ShipCity=London

    //  Orders: OrderDate=3/11/1997     ShipCity=London

    //  Orders: OrderDate=3/24/1997     ShipCity=London

    //  Orders: OrderDate=5/15/1997     ShipCity=London

    //  Orders: OrderDate=5/16/1997     ShipCity=London

    //  Orders: OrderDate=6/24/1997     ShipCity=London

    //  Orders: OrderDate=7/15/1997     ShipCity=London

    //  Orders: OrderDate=3/11/1998     ShipCity=London

    //  Orders: OrderDate=3/13/1998     ShipCity=London

    //  Orders: OrderDate=4/14/1998     ShipCity=London

     

    Wish 6:

    Now last but not the least let us involve OrderDetails table to get the price of each order.

     

     

    var t = from c in customers 

            where c.City == "London"

            select new {

                c.CompanyName,

                Orders =                            

                        from o in c.Orders      

                        from od in o.OrderDetails

                            select new {o.OrderDate,

                                    TotalPrice =

                                    (((float)od.Quantity * (float)od.UnitPrice)

                                                            - (float)od.Discount)}

                       };

    ObjectDumper.Write(t,1);                        

    /*Output:

    CompanyName=Around the Horn     Orders=...

      Orders: OrderDate=11/15/1996    TotalPrice=90

      Orders: OrderDate=11/15/1996    TotalPrice=390

      Orders: OrderDate=12/16/1996    TotalPrice=96

      Orders: OrderDate=12/16/1996    TotalPrice=195

      Orders: OrderDate=12/16/1996    TotalPrice=608

      Orders: OrderDate=2/21/1997     TotalPrice=152.9

      Orders: OrderDate=2/21/1997     TotalPrice=299.9

      Orders: OrderDate=6/4/1997      TotalPrice=237.5

      Orders: OrderDate=6/4/1997      TotalPrice=1060

      Orders: OrderDate=6/4/1997      TotalPrice=210

      Orders: OrderDate=6/4/1997      TotalPrice=590.4

      Orders: OrderDate=6/4/1997      TotalPrice=45

      Orders: OrderDate=10/16/1997    TotalPrice=504

      Orders: OrderDate=10/16/1997    TotalPrice=780

      Orders: OrderDate=10/16/1997    TotalPrice=419.85

      Orders: OrderDate=11/14/1997    TotalPrice=284.8

      Orders: OrderDate=11/17/1997    TotalPrice=335.95

                */

     

    Ohh!!! It is weekend. I crossed a day (lost another day J).  Happy weekend.

     

    Namoskar!!!

     

     

     

  • Wriju's BLOG

    2007 Microsoft Office Add-in: Microsoft Save as PDF or XPS

    • 2 Comments

     

    If you are Office 2007 user, I bet if you download and use this add-in your going to enjoy the power.

     

    So go ahead and download http://www.microsoft.com/downloads/details.aspx?FamilyID=4d951911-3e7e-4ae6-b059-a2e79ed87041&DisplayLang=en

     

    Namoskar

     

Page 23 of 24 (599 items) «2021222324