Friday, November 7, 2014

Debugging Routes - ASP.NET MVC

After creating Custom Routes, you have to check whether your routes work perfectly with your given URL or not. For that, you have to debug your routes. To Debug Routes, you have to download one DLL from the http://code.haacked.com/mvc-1.0/RouteDebug-Binary.zip and add a reference into your MVC Application.
Now debug route you have to write the following line of the code into the Global.asax Application Start Event.

RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);

And run your application. You will see the below screen in your browser:

RouteTesting.JPG
You can see all the custom routes into All Routes Table and it will show that your browser URL matches with which Routes. If it will match any Routes, it will show true into the Match Current Request Routes, otherwise it will show false. You can check with another URL, for that you have to write URL into the Address Bar.

Saturday, November 1, 2014

A Technique for Maintaining Scroll Position on Postback in ASP.NET 2.0

Page directive supports a feature to maintain scroll position on page PostBack.  As we add the below page directive.






Above code inject JavaScript to return scroll position and also add state to hidden field to remember scroll position.

How asp.net Asynchronous page work?

Please find below video from http://www.pluralsight.com/ for Asynchronous page in asp.net.

Friday, October 31, 2014

Programming Stuff: SOME NEW TECHNOLOGIES FOR VISUAL STUDIO

Programming Stuff: SOME NEW TECHNOLOGIES FOR VISUAL STUDIO: NCrunch for VS This software provides an inbuilt ADDON for VS for automatically executing your defined unit tests on your code. How i...

SOME NEW TECHNOLOGIES FOR VISUAL STUDIO

  1. NCrunch for VS
This software provides an inbuilt ADDON for VS for automatically executing your defined unit tests on your code.
How it works:
  • You create your program
  • You create your unit tests
  • Ncrunch automatically detects unit test methods and keeps executing in memory
  • As soon as you modify something in your program and while you are writing the buggy code, ncrunch on that line itself will give you a prompt that, with this code change this unit test method is breaking
  1. Microsoft Pex
This is more intelligent version of ncrunch you can say. This is more interesting too J. It’s a VS add on kind of software from Microsoft that once you install, gives you an option in your code with any method as “create PEX possible unit tests for this method”. Once selected, intelligently it would create n number of all posibble unit test methods for your code with all possible combinations of parameters that you have defined for your method. Actually you can play around without installing anything on service URL they have given.
How it works:
  • You create your program
  • You right click on method name and select “create pex unit test methods”
  • Once selected, it will create all possible combination of unit test methods for your method with all possible variations and will also execute and will let you know the results

Friday, October 17, 2014

Introducing WCF :- Next-generation connected systems on Windows

Outline 

  1.  Connected systems overview 
  2.  The move towards "services" 
  3.  Service-orientation 
  4.  Introduction to WCF 
  5.  WCF programming model basics 
  6.  Common WCF questions 

1.What is a connected system? 

  • An application that is distributed across multiple computer nodes  

Building connected systems on Windows 

  • MS has shipped many communication frameworks over the years  

2.The move towards "services" 

  • Demand for technology freedom and interoperability is common now  Services expose units of functionality via messaging Interop achieved via standard protocols and message formats

Service design philosophies 


SOAP + WS-* services 

  •  The industry has defined a complete protocol stack for services Typically implemented with RPC-based toolkits, feels a lot like COM+.

RESTful services 

  •  RESTful services typically embrace HTTP, the "Web" transport 
    •  Services are modeled as "resources" with unique identifiers (URI's) 
    •  HTTP defines a uniform service contract: GET, POST, PUT, DELETE (CRUD)
    •  Resources can be represented as XML, RSS, JSON, etc
  •  HTTP provides numerous features for security and scalability
    •  A successful design pattern used throughout the Web today 

3. Service-orientation 

  • Service-orientation is a design paradigm for separation of concerns 
  •  Focused on autonomy, explicit boundaries, contracts & policies 
  •  Design principles help achieve a Service Oriented Architecture (SOA) 
  •  SOA says nothing about technology – room for both SOAP & REST 

      The ideal communication framework 


4. Introducing WCF 

       WCF is the new unified "communications" framework for Windows


Services and endpoints 


  • With WCF, you write services that expose endpoints to the world
    • Service implementation defines business logic
    • Endpoints define the communication options
    • Services can expose multiple endpoints for consumers

What is an endpoint? 

  •  Endpoints tell WCF how to build the runtime communication channels

Consuming services with WCF 


  • Clients need to know several things in order to consume a service 
    • Where to send the message (address) 
    • How to send the message, such as what transport/protocols to use (binding) 
    • What the messages should contain (contract)

WCF clients 

  • With WCF, you consume services via channels based on endpoints 
    •  Clients retrieve endpoint definitions from service metadata 

Summary 


  • WCF provides a unified model with flexibility in communications 
    •  Your choice of architecture, transport, message format, protocols, etc 
    •  Replaces the need for the preceding Windows frameworks 
  •  There are several good reasons to begin moving towards WCF 
    •  It provides a simpler model that will increase productivity/reach 
    •  Microsoft has positioned it as the "DCOM" of the next decade 

Basic about Fiddler

Overview

  1. HTTP 
  2. Requests 
  3. Responses 
  4. What is Fiddler? 
  5. Why Use Fiddler? 
  6. How does Fiddler Work? 
  7. Where to get Fiddler? 
  8. Basic Usage  

  1. HTTP 

  • HyperText Transfer Protocol
  • Protocol defined in RFC 2068 (Http 1.1), January 1997 
  • http://www.ietf.org/rfc/rfc2068.txt 
  • Request/response paradigm 
  • Header and body  

2.HTTP Request 

3.HTTP Response  

4.What is Fiddler? 

  •  Freeware HTTP tracing tool 
  •  Shows complete request and response (not packets)  
  •  Created by Eric Lawrence (@ericlaw) 
    •  Microsoft, Program Manager on IE team
    •  First version 0.8, October 2003
  • C# 

5. Why Use Fiddler? 

  • Troubleshoot problems 
  • Performance evaluation
  • Fiddle with requests and responses 
  • Security testing 
  • Visualize page requests (timeline) 
  • Periodic site reviews 

6.How Does Fiddler Work? 

  •  Proxy 
  •  Local 
  •  Remote (smart phones, tablets, non-Windows platforms) 
  •  Adjusts browser’s proxy configuration to intercept traffic 
    •  Many of the latest browsers work with localhost and 127.0.0.1 (automatically) 
    •  ipv4.fiddler or ipv6.fiddler 
  •  NOT a wire/network monitor! 

7.Where to Get Fiddler? 

  • http://fiddler2.com 

8.Basic Fiddler Usage 

  •  Capture traffic 
  •  Review “sessions” 
  •  Statistics 
    • Number of Requests 
    • Bytes received 
    • Chart  
  • Timeline 
  • Inspectors 
  • Save as .saz file  

Summary 

  •  HTTP protocol used to communicate between web browsers and web servers 
  •  Fiddler is a great freeware tool that shows web requests and responses 
  •  Fiddler acts as a proxy for browsers and even other platforms and devices 
  •  Reviewed basic common usage of Fiddler 

Coalescing operator - ??

How Coalescing operator works?
Note 
Here I am just going to show how coalescing operator replace ternary operator. i.e not comparing ternary operator with coalescing operator.
Ternary Operator
Syntax
?
1
Type variable = booleanCondition ? exp1 : exp2;

Ternary operator assign exp1 to variable if the booleanCondition return true or exp2 if booleanCondition return false.
Consider Case were I am coding with the nullable type using ternary opertor.

Example
?
1
2
3
Nullable<int> a = null;
Nullable<int> b = 10;
int c = a==null ? b.Value : a;

Coalescing operator
Coalescing operator work some what similar to ternary operator but it works only with the Nullable types only. so its sort hand operator to deal with Nullable types only.

Syntax
?
1
Type variable = nullalbeTypeVariable1.Value ?? nullableTypeVariable2.Value;

Operator its check value of nullalbeTypeVariable1 if its as real value rater tan null it assin value to variable else assign value of nullableTypeVariable2.

Example
?
1
2
3
Nullable<int> a = null;
Nullable<int> b = 10;
int c = a ?? b.Value;

Summary
Coalescing operator deals with Nullable type and its sort for long ternary operator expression.