Search This Blog

Thursday, 30 June 2011

JetBrains dotPeek EAP is Open!

dotPeek is a new free-of-charge .NET decompiler from JetBrains, the makers of ReSharper and more developer productivity tools.

What's Cool about dotPeek?

  1. Decompiling .NET 1.0-4.0 assemblies to C#
  2. Quick jump to a specific type, assembly, symbol, or type member
  3. Effortless navigation to symbol declarations, implementations, derived and base symbols, and more
  4. Accurate search for symbol usages
    with advanced presentation of search results
  5. Overview of inheritance chains
  6. Support for downloading code from source servers
  7. Syntax highlighting
  8. Complete keyboard support
  9. dotPeek is free!
You can download it here

Tuesday, 28 June 2011

Windows Azure Seminar on 31st July 2011


Hi,

I am arranging a free seminar on Windows Azure on 31st july. There are
limited seats and session is strictly for my old students..

Date: 31st july 2011
Time : 9 am start
Duration: 4 hrs
Place: TBD

Entry by registration only for first 20 on first come first server basis

Monday, 20 June 2011

Warming up to WCF -- Web Services Part 3

How will make your web services stateful?
Or
This question can be asked as how to implement session in your web services?

Web services run on HTTP with underlying message protocol as SOAP, now since HTTP in its nascent form is stateless so are XML web services in .net. Now the question arises if web services are stateless, then how can we make our web services store user session information… Let’s look at the approach.

First Things first, we will make use of some of the properties of WebMethod attribute to enable session in a web service as follows


    [WebMethod (EnableSession=true)]
    public void SessionStart()
    {
        Session["username"] = "Shakti";
      
    }

    [WebMethod(EnableSession = true)]
    public string SessionEnd()
    {
        return "Hello  " + Session["username"];
    }

Now create a new project which will act as a client, it can be a windows form application or a Web site. For this sample I am taking a windows form..

In client add a reference to the service created above.

Add below code to access the service

       localhost.Service obj = new localhost.Service();
     obj.CookieContainer = new System.Net.CookieContainer();

     obj.SessionStart();

     Console.WriteLine( obj.SessionEnd());

And here is the output

Hello  Shakti

If you look at client code closely you will see below line

obj.CookieContainer = new System.Net.CookieContainer();

How it works?

We are storing session information in the proxy itself which is a part of client process so nothing is being stored on the server.
 

Sunday, 19 June 2011

OOPS Session Updates Held on 19th June

Another great session..In all 25 people attended the session which included a mix of freshers and experienced candidates from companies like HCL, CKlear, FISERV, WNS , GlobalLogic etc..
So if you haven't been able to attend the last 2 sessions, now is the last chance for you,..Next session will be on 26th june after which I will take a break since it becomes very hectic working on weekends :)

Please spread the word to your friends and attend to gain some invaluable experience..

Thanks,
Shakti

Thursday, 16 June 2011

Warming up to WCF -- Web Services Part 2

Now, since we have already covered some basics let’s jump to questions that we asked at the very beginning:-

Do web services support method overloading?

Web services do support method overloading but it’s turned off by default due to web service internationalization. Since web services are designed so that they can be used everywhere (all technologies) so some standards must be followed while creating your service so that they follow basic language rules followed by all programming languages.

This is how your web service looks like…

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class Service : System.Web.Services.WebService
{
    public Service () {

        //Uncomment the following line if using designed components
        //InitializeComponent();
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
   
}

Have a look at WebServiceBinding attribute above... What is it doing here?
It says that web service conforms to BasicProfile1_1 which is actually the standards that you must follow to internationalize your web service.

WS-I is web service internationalization. You can find more information here

Since this is the default value of attribute, if you try to overload the service it will throw error when you try to run the service. Reason is simple enough… Not all programming languages of world support method overloading so if your web service is internationalized it should also not expose overloaded methods. What if I am developing web service for my company’s intranet and I know that all my clients are going to be .Net clients… In that case you can modify your service to enable method overloading but you need to follow below steps:-

1.)   As a first step you need to change WsiProfiles.BasicProfile1_1 to WsiProfiles.None

2.)   Secondly, Provide a MessageName attribute to one of your methods.
           
        [WebMethod (MessageName="Test")]
      public string HelloWorld() {
           return "Hello World";
      }

    [WebMethod]
    public string HelloWorld(string name)
    {
        return "Hello World " + name;
    }


        What is the purpose of this MessageName attribute?
   
    It all boils down to WSDL. As you should know that all web services expose a WSDL file to clients which contains all the operations (methods) exposed by the service and their equivalent SOAP representations. So for a method accepting an input and returning an output there will be one SOAP INPUT element and one SOAP OUTPUT element in WSDL. The SOAP INPUT will have same name as that of operation (method) and SOAP OUTPUT will be operation name with Response appended to it…Lets see the SOAP part of method after overloading…


<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="Test">
  <s:complexType />
  </s:element>
<s:element name="TestResponse">
<s:complexType>
<s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="TestResult" type="s:string" />
  </s:sequence>
  </s:complexType>
  </s:element>
<s:element name="HelloWorld">
<s:complexType>
<s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="name" type="s:string" />
  </s:sequence>
  </s:complexType>
  </s:element>
<s:element name="HelloWorldResponse">
<s:complexType>
<s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string" />
  </s:sequence>
  </s:complexType>
  </s:element>
  </s:schema>
  </wsdl:types>


Thus if you have two methods with same name without a MessageName attribute, in that case there will be 2 same soap request and response generated in WSDL which is not a valid scenario… Thus that won’t compile.

Warming up to WCF -- Web Services Part 1

The world has moved to WCF but still when you go for an interview, most of the people ask you questions on web services before actually moving out to WCF...

Some very common and important question that people generally ask regarding web services are:-

1.) Do web services support method overloading?
2.) How will make your web services stateful?
3.) How will you design your service in a way that you can change the deployment     address with minimal fuss?
4.) What are the disadvantages of DCOM over web services?
5.) Why did MS created web services when there was a proprietary standard already available in form of DCOM?

Let’s start diving into the beautiful world of .Net web Services also known as XML web services...
.Net web services are a successor to DCOM (Distributed component object model)...So let’s first understand the limitations of DCOM which led to creation of Web Services:-

Limitations and Problems with DCOM:

1.)      DCOM was created with assumptions that all the nitty-gritty’s will be managed by the organization. Means all the components that will make up the application as a whole will be managed by the organization creating the application, which is not always the case since we are dependent on lots of third party apps, and how they are creates (technology) and managed (platform) is out of our immediate control.

2.)      Since DCOM is based on a proprietary standard (invented by Microsoft), its only good for windows operating systems and not well suited for heterogeneous environments.

3.)      Tight coupling between client and server is another reason for not liking DCOM. Any changes to server will mean a ripple effect on client side component as well.

4.)      Since DCOM supports binary data and TCP protocol, it’s not suited well enough for internet based applications. Remotable applications created using DCOM comes with extra burden of opening and maintaining ports, which generally sit behind firewalls in normal internet scenarios using HTTP.

Thus Xml web services came into picture. Advantages of web services included

1.)     Interoperability:-
                  Web services work out of private networks, generally deployed on a shared or           dedicated hosting environment and managed separately and thus the offer               better return on investments since one solution          can be used from multiple              places reusability) and by multiple clients since web services use SOAP over               HTTP. Web services are used to build platform independent solutions.

2.)     Reusability:-
                  With web services entire business logic can be separated into multiple web                services and let the client choose which business logic they want. So client is                  free to choose what they need instead of giving them everything as a bunch.

3.)     Deployability:-
                  Since web services are deployed over standard internet technologies, they               can be deployed over firewalls and there is no need to open additional ports                   since it’s accessible via Http ports 80 for http and 443 for https.

Still there were some disadvantages of web services:-

1.)   Security was not built into web services. Though it used built in windows authentication as well as forms authentication, we needed a well defined security framework for web services. Microsoft and IBM worked on a joint initiative which is later called WSE (Web Services Enhancements) which works as a layer over web services providing it features like security, transaction management, policy management etc.
2.)   SOAP, the underlying protocol on which web service is based is both a boon and a bane. It allows disparate system and technologies to interact with each other but if my client server is same (technology wise) then this is an overhead due to parsing of request and response at both ends. Web services doesn’t provide the flexibility to choose/switch between messaging standards i.e. SOAP for non .net client and XSD for .Net client.
3.)   Since web applications are stateless so are web services and there is extra work that’s needed at client side to make it work like a stateful service.

Feel free to comment if some more pros and cons come to your mind. I know there are lot more…

Monday, 13 June 2011

Has HTML5 Actually killed Silverlight

There have been lots of hue and cry over how HTML5 being superior than silverlight and how it will kill silverlight..Lots have been said regarding this but if you actually look at where silverlight actually makes sense then you will be amazed by the potential it provides for a .Net developer like me..
I have really been fascinated to mobile phone programming off late, More so since telecom industry is still an untapped industry in india( compared to other countries) and there is huge potential in gaming market whose boom is yet to come..Most of the people in india are still using mobile for receiving a call and sending an SMS but the potential for mobile application is huge and will increase with awareness..
Off late I have seen my friends using geolocator services in their mobile phones to search for routes while on a trip..
How do I create these applications as a .Net developer since what i know about mobile apps is that they are created in objective C or some other .Net languages..With the advent of silverlight it has opened a new dimension for a .net developer to start work on mobile apps...You can use silverlight to create applications for Windows Phone..
Below is an article from Tom Warren why Silverlight is not dead...
Please follow the link for complete story

OOPS Session Updates Held on 12th June

It was a great session..In all 27 people attended the session which included a mix of freshers and experienced candidates from companies like Fiserv , HCL , Miracle, RBS , NIIT etc..
Good to see some renowned trainers also attending the session..In all it was a great experience and I really enjoyed delivering it..
Thanks all for the support..
Hoping to get same kind of response in sessions that will be held on 19th and 26th june..
Please spread the word to your friends and attend to gain some invaluable experience..

Thanks,
Shakti

Sunday, 5 June 2011

Free OOPS Session in C#

Hi ,
I am organizing Free Session on OOPS in C# on 12th, 19th and 26th June. Please feel free to come... Feel free to bring in your friends..
Date: 12th/19th/26th June
Event: OOPS and .Net framework from beginner to advanced
Timing: 9.30 am -12.30
Fees: N/A Sessions are meant for information sharing
Why This Training: As a part of Microsoft's Community initiative
More about Trainer:-
· Gold level member on site http://www.dotnetspider.com/
· Star Level member on Microsoft official site www.asp.net. Currently holding 1st rank in Top Answerers list in Forums on http://forums.asp.net/

Trainings conducted
Company
Subjects
Duration
JobSeeders
Advanced ASP.Net with AJAX, OWASP
3 Months
JobSeeders
WCF, WPF & Silverlight
3 Months
JobSeeders
Advanced .Net
3 Months
Miracle
MOSS & WSS
5 days
Miracle
SharePoint Server Administration
7 days
Fiserv
.Net 4.0 , ADO.Net entity framework 4.0, MEF
4 days
Fiserv
.Net Design Patterns
3 days
Fiserv
OWASP web application security
2 days
Fiserv
.Net 3.5 including WCF,WPF,WF
5 days
RSystems
Advanced .Net 3.5
4 days
RSystems
.Net 3.5
6 days
Miracle Technologies
MCTS training
1 Month
RSystems
Advanced .Net with .Net 3.0
4 days
RSystems
Advanced Asp.net with Vb.Net
12 days
RSystems
Asp.net with C#
2 days
Fidelity, Chandigarh
Advance Xml, XSL and XSD
2 days
Tata Energy Research Institute, Delhi
Advance C#, Vb.Net and Asp.Net
3 days
TCS, Noida
Advance C#, Vb.Net and Asp.Net
4 days
CSC,Noida
1. SOAP
2. Asp.Net and Ado.Net and XML
5 days
CSC,Noida
Introduction to .Net framework using C#
1 Day
CSC,Noida
C#, Exposure to Asp.Net, Ado.Net, Xml in .Net
4 days
C-DAC, Noida
XML & Web Services
2 Days
Synergy Systems, Noida
C#, Exposure to Asp.Net,
Exposure to VB.Net
4 Days
C-DAC, Noida
C Data Structures
1 day
Location: -
12th, 19thand 26th june – Skjobseeders Training & placements, 3/2 West Guru Angad Nagar, Delhi-92 ( Near Nirman vihar Metro station,east delhi)
18th June : Aradhya Tutorials , 1st floor , Pul bangash Metro station
Feel free to contact me on 9891971113 for more information. Please pass on this information to your friends so that they also can be benefitted.


Thanks & Regards,
Shakti Singh Tanwar

Friday, 3 June 2011

How to Store Viewstate to Persistence Medium

In this article we will discuss about How to store ViewState of a Page/Control on server or a custom data store like sql server or file.

As you all know ViewState is stored as part of html sent to your browser in form of hidden field. This is the default behavior of asp.net framework. Starting asp.net 2.0 you have more control over how & where view state should be stored? First of all let’s understand the reason behind not sending viewstate to client:-

1.)    ViewState can be tempered with on client side with tools like firebug, fiddler etc.

2.)    ViewState makes page bulky and page loading process becomes slow.

Asp.net 2.0 introduced two methods which help us out in this process:-

1.)    LoadPageStateFromPersistenceMedium

2.)    SavePageStateToPersistenceMedium

LoadPageStateFromPersistenceMedium loads viewstate data from your custom storage.

SavePageStateToPersistenceMedium saves viewstate data to persistence medium.

So let’s try to understand this with an example

1.       Create an empty website in visual studio

2.       Add a page say Default.aspx

3.       Write below code in aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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

<head runat="server">

    <title></title>

</head>

<body>

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

    <div>

        <table>

            <tr>

                <td>

                    <asp:DropDownList ID="DropDownList1" runat="server">

                     

                    </asp:DropDownList>

                </td>

            </tr>

            <tr>

                <td>

                    <asp:TextBox runat="server"></asp:TextBox>

                </td>

            </tr>

            <tr>

                <td>

                    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

                </td>

            </tr>

        </table>

    </div>

    <p>

    </p>

    </form>

</body>

</html>



4.       In code behind file write below code

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.IO;

using System.Text;



public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            List<ListItem> items = new List<ListItem>();

            items.Add(new ListItem("1"));

            items.Add(new ListItem("2"));

            items.Add(new ListItem("3"));

            DropDownList1.DataSource = items;

            DropDownList1.DataBind();

        }

    }



    protected override object LoadPageStateFromPersistenceMedium()

    {

        if (Session["DefaultPageViewState"] != null)

        {

            string viewStateString = Session["DefaultPageViewState"] as string;

            TextReader reader = new StringReader(viewStateString);

            LosFormatter formatter = new LosFormatter();

            object state = formatter.Deserialize(reader);

            return state;

        }

        else

            return base.LoadPageStateFromPersistenceMedium();

        //return null;

    }



    protected override void SavePageStateToPersistenceMedium(object state)

    {

        LosFormatter formatter = new LosFormatter();

        StringWriter writer = new StringWriter();

        formatter.Serialize(writer, state);

        Session["DefaultPageViewState"] = writer.ToString();

       

    }

    protected void Button1_Click(object sender, EventArgs e)

    {



    }

}



Open page in browser and page loads up with values in dropdown list.


Right click page and click View Source. See highlighted portion below..The viewstate field is empty.


Click the button to perform postback. You will see the dropdown still loads with data i.e. ViewState has been persisted and is working fine.

Just to cross check if our code is actually working. Comment out code in LoadPageStateFromPersistenceMedium method and return null instead. Again compile and run the code. Page will open fine first time but now click on postback , you will see dropdown losing data since it was stored in viewstate.