Pages






Monday, March 28, 2011

Creating an ASP.NET Web Service

Let's say that an online brokerage firm wants to provide a Web service to its customers. It could accomplish this by writing an ASP.NET Web application. However, the firm wants to extend the reach of its services so that they can be leveraged from other applications. For example, a portal site such as MSN or Yahoo! might want to provide these services but might lack the expertise or the desire to take on the burden of building the services themselves. Instead, the portal site can provide a UI to the customer and use the brokerage firm's Web service as the back end. At worst, the portal will retain the customer within its site and potentially increase its ad revenue. At best, the portal can charge an incremental amount on top of the fees provided by the brokerage firm. Either way, it is potentially a win-win situation for the portal company and the brokerage firm. In this chapter, I build the Securities Web service, which allows the client to perform actions such as obtaining a quote for a particular stock, bond, or mutual fund. The individual methods will contain skeleton implementations that let you focus on the mechanics of building Web services using ASP.NET. The first thing I need to do is define the endpoint for the Securities Web service. A Web service is defined by an .asmx file, which serves as the endpoint for the Web service. Calls made to .asmx files are intercepted and processed by the ASP.NET runtime. The implementation of the Web service is encapsulated within a class. The class definition can either appear inline within the .asmx file or be contained in a separate dynamic link library (DLL). The .asmx page needs to contain information that the runtime can use to locate the class. Each .asmx page contains a directive at the top of the page that specifies where and in what form the implementation of the Web service can be found. This directive is used by the ASP.NET runtime to bind the Web service to a class that contains the implementation. Here is an example in which the implementation of the Web service is contained within the .asmx file: <%@ WebService Language="c#" Class="BrokerageFirm.Securities" %>namespace BrokerageFirm { // Inline definition of the Securities class public class Securities { Implementation... } } The Class attribute contains the fully qualified name of the class that implements the Web service. If the code resides within the .asmx file, you must set the Language attribute, which specifies the language in which the code was written. The first time the Web service is accessed, the ASP.NET runtime will use the Language attribute to compile the code with the appropriate compiler. Thus, even if the code implementing the Web service is contained within the .asmx file, it will always be executed as compiled machine code. Out of the box, ASP.NET is configured to dynamically compile code written in C#, Visual Basic, Visual Basic .NET, and JScript .NET. You can configure additional languages within the web.config file or the machine.config file. The following is the compilation section of the machine.config file found in the C:\WINNT\Microsoft.NET\Framework\version\CONFIG directory: As you can see, the default language is Visual Basic .NET (vb), so my C# example must set the Language attribute to c#, cs, or csharp. The compilation section also includes a list of assemblies that are referenced by code within the .asmx file. If the Securities Web service were to reference entities from an assembly other than those listed in the preceding code, I could add a new machine-wide reference to my machine.config file or an application-wide reference to my web.config file. The last add element specifies a wildcard for the assembly name. If an assembly is referenced within an .asmx file that was not previously listed, the ASP.NET runtime will search for the assembly. (See the product documentation for the exact search order.) The class implementing the Web service can also reside within a compiled assembly. By convention, the assembly is placed in the Web application's bin directory because this directory is always included in the search path of the runtime. This is the default configuration for Web services created using Visual Studio .NET. The following is the WebService directive that Visual Studio .NET creates automatically: <%@ WebService Language="c#" Codebehind="Service1.asmx.cs" Class="BrokerageFirm
.Service1" %>As is typical in the Visual Studio product line, most of the attributes defined in the WebService directive are used by the editor and are ignored by the runtime. As I mentioned, you must specify the Language attribute only if the implementation of the Web service resides within the .asmx file. In addition, the code-behind file is always ignored by the ASP.NET runtime and is used by Visual Studio .NET to bring up the appropriate source code file when you select View Code within the IDE. One other potential gotcha is that Visual Studio .NET will only partially maintain this file. When you rename the .asmx file to something more meaningful, Visual Studio .NET will automatically rename the associated code-behind file and update the WebService directive accordingly. As a common practice, I also rename the class that implements the Web service to match the name of the .asmx file. Unfortunately, Visual Studio .NET will not automatically update the Class attribute. If you rename the class, you have to manually update this attribute yourself. Furthermore, double-clicking the .asmx file to update this attribute will display the design surface, not the file text. Visual Studio .NET does not provide the same buttons shown on an .aspx file's design surface that allow you to switch between the design view and the underlying text of the file. You have to right-click the file, choose Open With, and then select Source Code (Text) Editor. Now that I have discussed the two options—placing the implementation for your Web service within the .asmx file or within its own assembly—I am sure you are wondering which one you should use. Well, as with most design decisions, it depends. Placing the code within the .asmx file provides the simplest means of deployment because ASP.NET will compile the code dynamically for you. However, deploying the implementation within an assembly ensures that your code will not contain compilation errors. Also, if you are deploying the Web service outside the confines of your data center, others will not have access to the source code. Another potential advantage of having the implementation of your Web service reside within an assembly is that it can be directly referenced by other applications hosted on the same machine. For example, suppose I provide an HTML-based UI that allows my customers access to the functionality of the Securities Web service. If the class containing the implementation of the Web service is in its own assembly, the Web application can reference the assembly and directly access the Web service class. This avoids the unnecessary overhead of accessing the functionality remotely. You should take this approach with caution, however. Some Web services rely on services provided by the ASP.NET runtime to function correctly. For example, a Web method might set an attribute stating that the ASP.NET runtime must create a new transaction on its behalf. Because ASP.NET is responsible for ensuring that a transaction is created, no transaction will be created if the class implementing the Web service is accessed directly. Regardless of which option you choose, the code for implementing the Web service will be the same. For starters, I will implement one method within my Securities Web service, InstantQuote. Plenty of services on the Web give quotes on the price of a company's stock. However, these quotes are often time delayed and can be more than 20 minutes old. InstantQuote will use an extremely complex algorithm to obtain the price a security is trading at on the floor. Following is the implementation. using System; using System.Web.Services; namespace BrokerageFirm { public class Securities : WebService { [WebMethod] public double InstantQuote(string symbol) { double price = 0; switch(symbol) { case "MSFT": price = 197.75; break; case "SUNW": price = 2.50; break; case "ORCL": price = 2.25; break; } return price; } } } All right, so the algorithm is not that complex. What do you expect with an example? The important thing to note is that the implementation of the Web service is a standard public class declaration with a WebMethod attribute decorating the InstantQuote method. This class declaration can be either compiled into an assembly or placed as is within the .asmx file, and it is the same whether it is contained within the .asmx file or compiled into a separate DLL. Each method that is intended to be exposed by the Web service must be public and must be decorated with the WebMethod attribute. This tells the ASP.NET runtime to expose the method as publicly accessible. From this point on, I will refer to a method of a class decorated with the WebMethod attribute as a Web method. When you decorate a method with the WebMethod attribute, you can also set various properties that modify the behavior of the ASP.NET runtime. Table 6-1 lists the properties exposed by the WebMethod attribute. Table 6-1 Properties of the WebMethod Attribute Property Description BufferResponse Specifies whether the response to the client should be buffered. CacheDuration Specifies the amount of time, in seconds, that a response will be cached in memory by the Web server for a given response. The default is 0. Description Specifies the value of the description element under each operation element within each type definition within the ASP.NET-generated WSDL document. EnableSession Specifies whether the ASP.NET session state services will be available for the implementation of the method. MessageName Specifies the name of the method exposed by the Web service. Specifically, it sets the name of the element within the body of the SOAP message that contains the parameters as well as the suffix of the SOAP action. It also specifies the prefix of the names of the message, input, and output elements within the ASP.NET-generated WSDL document. TransactionOption Specifies the transactional support that should be provided for the implementation of the method. The method can serve only as the root of a transaction and cannot participate in the caller's transaction. The ASP.NET page framework also provides the WebService attribute. This attribute is set at the class level and is used to modify properties of the Web service as a whole. Changes made via the WebService attribute will be reflected in the Web service's WSDL document. Table 6-2 lists the properties exposed by the WebService attribute. Table 6-2 Properties of the WebService Attribute Property Description Description Specifies the description element under the service element within the ASP.NET-generated WSDL document. Name Specifies the name of the service element within the ASP.NET-generated WSDL document. It also specifies the prefix for the names of the portType, binding, and port elements. Namespace Specifies the target namespace for the WSDL document as well as the schema document that defines the structures for encoding the parameters within the body of a SOAP message. It also specifies the prefix of the namespace for the schema that contains any custom types defined by the Web service and the value of the SOAP action. Now that I have defined the Securities Web service, let's talk about how clients can access it.

SOAP

At the core of Web services is Simple Object Access Protocol (SOAP), which provides a standard way of packaging messages. SOAP has received a lot of attention because it facilitates RPC-style communication between a client and a remote server. But plenty of protocols have been created to facilitate communication between two applications—including Sun's RPC, Microsoft's DCE, JAVA's RMI, and CORBA's ORPC. So why is SOAP getting so much attention? One of the primary reasons is that SOAP has incredible industry support. SOAP is the first protocol of its kind to be accepted by practically every major software company in the world. Companies that rarely cooperate with each other are rallying around this protocol. Some of the major companies that are supporting SOAP include Microsoft, IBM, Sun Microsystems, SAP, and Ariba. Here are some of the advantages of SOAP: It is not tightly coupled to one language. Developers involved with new projects can choose to develop in today's latest and greatest programming language. But developers who are responsible for maintaining legacy applications might not have a choice about the programming language they use. SOAP does not specify an API, so the implementation of the API is left up to the programming language (such as Java) and the platform (such as Microsoft .NET). It is not tightly coupled to a particular transport protocol. The SOAP specification does describe how SOAP messages should be bound to HTTP. But a SOAP message is nothing more than an XML document, so it can be transported over any protocol that is capable of transmitting text. It is not tied to any one distributed object infrastructure. Most distributed object systems can be extended (and some of them are) to support SOAP. It is important to realize that even with SOAP, middleware such as COM+ still plays an important role in the enterprise. Component middleware is still responsible for some of the more advanced object management features such as object lifetime management, transactions, object pooling, and resource pooling. SOAP enables a degree of interoperability between different systems that are running component middleware from competing vendors. It leverages existing industry standards. The primary contributors to the SOAP specification intentionally avoided reinventing anything. They opted to extend existing standards to meet their needs. For example, SOAP leverages XML for encoding messages. Instead of using its own type system, SOAP leverages the type definitions already defined within the XML Schema specification. And as I have mentioned, SOAP does not define a means of transporting the message; SOAP messages can be bound to existing transport protocols such as HTTP and SMTP. It enables interoperability across multiple environments. SOAP was built on top of existing industry standards, so applications running on platforms that support these standards can effectively communicate via SOAP messages with applications running on other platforms. For example, a desktop application running on a PC can effectively communicate with a back-end application running on a mainframe that is capable of sending and receiving XML over HTTP. This chapter covers the following key aspects of the SOAP specification: The SOAP envelope. This is used to encode header information about the message and the body of the message itself. SOAP Encoding. This is a standard way of serializing data into the body of a SOAP message. RPC-style messages. I discuss the protocol you can use to facilitate procedure-oriented communication via request/response message patterns. The HTTP POST protocol binding. This is the standard method of binding SOAP messages to HTTP. Before I go any further, I want to discuss the status of SOAP. This chapter was written against version 1.1 of the SOAP specification (http://www.w3.org/TR/SOAP). The World Wide Web Consortium (W3C) is continuing to develop SOAP. On July 9, 2001, a working draft of SOAP 1.2 was published (http://www.w3.org/TR/2001/WD-soap12-20010709) by the XML Protocol Working Group. As an acknowledgment of the phenomenal industry support that SOAP enjoys, the XML Protocol Working Group is committed to maintaining a smooth migration path from SOAP 1.1 to SOAP 1.2. Many of the proposed modifications are fit-and-finish and do not radically alter the use of SOAP. Much of what you have learned about SOAP 1.1 will directly translate to SOAP 1.2. In addition, the majority of the Microsoft products that incorporate SOAP will likely not adopt SOAP 1.2 until it becomes an official W3C recommendation. Therefore, I recommend that you focus on learning the SOAP 1.1 protocol with an eye on the deltas in version 1.2.

A Simple Commerce Application

You will first create an ASP.NET Web Form that collects and validates credit card information. The Web Form allows users to enter their credit card information, and then it informs users whether the information they entered is valid. You then move the credit card validation logic into a Web service and modify the Web Form so that it calls the Web service to validate the credit card information. Creating a Web Form You can create a Web Form by opening Visual Studio .NET and creating a new Web Application project. Set the project type to your language of choice, and select the Web Application template. Name your project Commerce, and set the location to a URL that points to the targeted Web server, as shown here: Visual Studio .NET creates a project on the specified Web server and places template Web application files into that directory. Included in these files is a Web Form page named WebForm1.aspx. Rename it Order.aspx, and then change the name of the class defined within Order.aspx from WebForm1 to Order by following these steps: Open the Order.aspx code-behind file by right-clicking on the filename in Solution Explorer and selecting View Code. Change the name of the WebForm1 class and its corresponding constructor to Order. In the Properties pane, change the name of the label to Status, the text of the label to Please enter your credit card information, the name of the button to PlaceOrder, and the text of the button to Place Order. After you adjust the layout and add some additional text, the Web Form should look similar to the following: Next you provide the implementation for the Place Order button. To add an event handler for the order button, double-click it and write the following code so that when the user clicks the button, the Validate method is called to determine whether the credit card information the user entered is valid. The code will also adjust the label's text to display appropriate text to inform the user whether the credit card was valid. public void PlaceOrder_Click(object sender. Syste.EventArgs e) { if(Validate(TextBox1.Text, Calendar1.SelectedDate)) { Status.Text = "Thank you for your order."; } else { Status.Text = "Credit card invalid."; } } Next you create the Validate method immediately following the PlaceOrder_Click method. public bool Validate(string cardNumber, DateTime expDate) { if(expDate >= DateTime.Today) { int total = 0; int temp = 0; char [] ccDigits = cardNumber.ToCharArray(); for(int i = 0; i < cardNumber.Length; i++) { if(((i+1)%2) == 0) { total += int.Parse(ccDigits[i].ToString()); } else { temp = int.Parse(ccDigits[i].ToString()) * 2; if(temp > 9) { temp = (int)temp - 9; } total += temp; } } if((total%10) ==0) { return true; } else { return false; } } else { return false; } } The Validate method determines whether the expiration date has passed. If it has not, the Validate method uses a standard mod10 algorithm to validate the credit card number. Now compile and test the Web application to ensure that it works as expected. Creating a Payment Web Service At this point, the validation functionality is embedded in the Web Form. Now I will show you how to leverage the validation functionality within other applications. For example, you might want to develop a WinForm application for running the cash registers. This application would probably need to call the same logic to validate credit cards. If you expose the validation logic as a Web service, any application that can send and receive XML over HTTP will be able to invoke the service to validate credit card information. You have a couple of options for creating the new Web service. You can simply add the Web service to an existing application by choosing Add Web Service from the Project menu. Or you can create a new project to contain the Web service. Recall that your intention is to have the credit card validation logic serve as a shared resource across multiple applications. It might have infrastructure and scalability requirements that differ from those of the commerce application. So, in this case you will create a separate application—a Visual Studio .NET Web service application. First open Visual Studio .NET and select Create New Project. Set the project type to your language of choice, and select the Web Service template. Name the project Payment, and set the location to a URL that points to the targeted Web server, as shown here: Change the name of the Service1.asmx file to CreditCard.asmx. Because it is good practice to have the class name match the name of the .asmx file, change the name of the Service1 class to CreditCard. Visual Studio .NET creates a code-behind file for the .asmx file similar to those it creates for .aspx files, so you must open CreditCard.asmx.cs to modify the class declaration. To view the code-behind file, right-click on CreditCard.asmx and choose View Code. Change the name of the Service1 class and its corresponding constructor to CreditCard. Next cut the Validate method from the Order Web Form and paste it into the CreditCard class. Then decorate the class with the WebMethod attribute and compile the application. The WebMethod attribute is the only code required to expose the Validate method on the Web! [WebMethod] public bool Validate(string cardNumber, DateTime expDate) { } The WebMethod attribute tells the ASP.NET runtime to provide all of the implementation required to expose a method of a class on the Web—including the ability to advertise the Web service's functionality in the form of Web Services Description Language (WSDL). Visual Studio .NET will use the automatically generated WSDL to create a reference to the Web service in your commerce application. Another service that ASP.NET provides the Payment Web service is the automatic generation of documentation for the Web service and a test harness. To invoke this functionality, use a Web browser to navigate to the CreditCard.asmx file, as shown here: Next test the Validate method using the test harness supplied with the documentation. Entering a valid credit card number and a date of 1/1/2052 produces the following results (assuming you are not reading a 50-year-old book): true As expected, the result is true. However, the XML response message is not a valid SOAP message. There are multiple ways in which an ASP.NET-hosted Web service can be called. The Web service will return a well-formed SOAP message only if the request was a SOAP message. I will discuss ASP.NET-hosted Web services in detail in Chapter 6. Updating the Order Web Form The next task is to switch back to the Commerce application and update the Order Web Form so that it calls the CreditCard Web service to validate the user's credit card. You first add a Web reference for the CreditCard Web service to the commerce application by using the Web Reference Wizard. You start the wizard by choosing Add Web Reference from the Project menu. In the Address text box, enter the URL to the server that hosts your targeted Web service. Click on the link to the Payment Web service that is listed in the right pane, as shown here: Click Add Reference. You should see the Web reference listed in Solution Explorer. Visual Studio .NET processes the WSDL metadata associated with the Payment Web service and automatically creates a proxy. You can think of WSDL as the Web services equivalent of a TypeLib. The resulting proxy allows the Web service to be treated like any other .NET class. Next you alter the implementation of the PlaceOrder_Click method to call the Web service instead of the local Validate function. First create an instance of the CreditCard class by using the new keyword as you would with any other .NET type. Notice that the default namespace for the Web service is the name of the server on which it resides. public void PlaceOrder_Click (object sender, System.EventArgs e) { localhost.CreditCard cc = new localhost.CreditCard(); Finally you call the Validate method on the cc object to cause a communication exchange to occur between the client (the Order Web Form) and the CreditCard Web service. if(cc.Validate(TextBox1.Text, Calendar1.SelectedDate)) { Status.Text = "Thank you for your order."; } else { Status.Text = "Credit card invalid."; } } If you are writing the code as you read this chapter, notice that you have full IntelliSense support for the cc object. After you type cc., the list of methods supported by the object, including the Validate method, will be shown. As soon as you type the opening parenthesis for the method, the parameters for the method will be displayed—including the .NET equivalent of the Web service's parameter types. As you have seen, it is easy to refactor a .NET application to expose its business logic via Web services. You simply copy the local method and place it into the .asmx code-behind file for the Web service. The only code required to expose the method via HTTP is the WebMethod attribute. Once the code is compiled and deployed, any client that supports HTTP and is capable of parsing strings can call the method.

Why Web Services?

Component-based programming has become more popular than ever. Hardly an application is built today that does not involve leveraging components in some form, usually from different vendors. As applications have grown more sophisticated, the need to leverage components distributed on remote machines has also grown. An example of a component-based application is an end-to-end e-commerce solution. An e-commerce application residing on a Web farm needs to submit orders to a back-end Enterprise Resource Planning (ERP) application. In many cases, the ERP application resides on different hardware and might run on a different operating system. The Microsoft Distributed Component Object Model (DCOM), a distributed object infrastructure that allows an application to invoke Component Object Model (COM) components installed on another server, has been ported to a number of non-Windows platforms. But DCOM has never gained wide acceptance on these platforms, so it is rarely used to facilitate communication between Windows and non-Windows computers. ERP software vendors often create components for the Windows platform that communicate with the back-end system via a proprietary protocol. Some services leveraged by an e-commerce application might not reside within the datacenter at all. For example, if the e-commerce application accepts credit card payment for goods purchased by the customer, it must elicit the services of the merchant bank to process the customer's credit card information. But for all practical purposes, DCOM and related technologies such as CORBA and Java RMI are limited to applications and components installed within the corporate datacenter. Two primary reasons for this are that by default these technologies leverage proprietary protocols and these protocols are inherently connection oriented. Clients communicating with the server over the Internet face numerous potential barriers to communicating with the server. Security-conscious network administrators around the world have implemented corporate routers and firewalls to disallow practically every type of communication over the Internet. It often takes an act of God to get a network administrator to open ports beyond the bare minimum. If you're lucky enough to get a network administrator to open up the appropriate ports to support your service, chances are your clients will not be as fortunate. As a result, proprietary protocols such those used by DCOM, CORBA, and Java RMI are not practical for Internet scenarios. The other problem, as I said, with these technologies is that they are inherently connection oriented and therefore cannot handle network interruptions gracefully. Because the Internet is not under your direct control, you cannot make any assumptions about the quality or reliability of the connection. If a network interruption occurs, the next call the client makes to the server might fail. The connection-oriented nature of these technologies also makes it challenging to build the load-balanced infrastructures necessary to achieve high scalability. Once the connection between the client and the server is severed, you cannot simply route the next request to another server. Developers have tried to overcome these limitations by leveraging a model called stateless programming, but they have had limited success because the technologies are fairly heavy and make it expensive to reestablish a connection with a remote object. Because the processing of a customer's credit card is accomplished by a remote server on the Internet, DCOM is not ideal for facilitating communication between the e-commerce client and the credit card processing server. As in an ERP solution, a third-party component is often installed within the client's datacenter (in this case, by the credit card processing solution provider). This component serves as little more than a proxy that facilitates communication between the e-commerce software and the merchant bank via a proprietary protocol. Do you see a pattern here? Because of the limitations of existing technologies in facilitating communication between computer systems, software vendors have often resorted to building their own infrastructure. This means resources that could have been used to add improved functionality to the ERP system or the credit card processing system have instead been devoted to writing proprietary network protocols. In an effort to better support such Internet scenarios, Microsoft initially adopted the strategy of augmenting its existing technologies, including COM Internet Services (CIS), which allows you to establish a DCOM connection between the client and the remote component over port 80. For various reasons, CIS was not widely accepted. It became clear that a new approach was needed. So Microsoft decided to address the problem from the bottom up. Let's look at some of the requirements the solution had to meet in order to succeed. Interoperability The remote service must be able to be consumed by clients on other platforms. Internet friendliness The solution should work well for supporting clients that access the remote service from the Internet. Strongly typed interfaces There should be no ambiguity about the type of data sent to and received from a remote service. Furthermore, datatypes defined by the remote service should map reasonably well to datatypes defined by most procedural programming languages. Ability to leverage existing Internet standards The implementation of the remote service should leverage existing Internet standards as much as possible and avoid reinventing solutions to problems that have already been solved. A solution built on widely adopted Internet standards can leverage existing toolsets and products created for the technology. Support for any language The solution should not be tightly coupled to a particular programming language. Java RMI, for example, is tightly coupled to the Java language. It would be difficult to invoke functionality on a remote Java object from Visual Basic or Perl. A client should be able to implement a new Web service or use an existing Web service regardless of the programming language in which the client was written. Support for any distributed component infrastructure The solution should not be tightly coupled to a particular component infrastructure. In fact, you shouldn't be required to purchase, install, or maintain a distributed object infrastructure just to build a new remote service or consume an existing service. The underlying protocols should facilitate a base level of communication between existing distributed object infrastructures such as DCOM and CORBA. Given the title of this book, it should come as no surprise that the solution Microsoft created is known as Web services. A Web service exposes an interface to invoke a particular activity on behalf of the client. A client can access the Web service through the use of Internet standards.

ASP.NET 2.0 AJAX

Duration: 3 Days (24 Hours)Prerequisite:• Exposure to Web application programming using ASP .NET with C# and connecting to Relational Databases from front end.• Good Knowledge in OOP concepts and java Scripts Course Approach:• Demo will be shown for the understanding of concepts wherever required • Hands on lab will be provided for all applicable topics• 50% Demo and Presentation ( first half of the day’s session ) and 50% of Hands on Lab ( second half of the day’s session ) DAY 1: Introduction to AJAX • Rich Internet Applications• Remote Scripting• AJAX Principles• HTTP Primer HTTP Requests HTTP Responses• AJAX Communication Techniques The Hidden Frame Technique XMLHttpRequests The XmlHttpRequest Object • XMLHttpRequest - Overview• Creating the Object • Asynchronous Data Transfers • The Ready State • HTTP Status Codes and Headers • Asynchronous Resource Retrieval• Retrieving XML Data• HTTP Response and Renderingo XML o JSON o Rendering the Response with CSS AJAX Framework • Sample Ajax and N-Tier Applicationo Presentation Layero Business Layero Data Layero Data Store• .NET Framework and Libraries• Understanding the .NET Libraryo Installing the Libraryo Using and Examining the Library• Ajax and Web Serviceso SOAP• Creating the Web Serviceo Building AJAX Applicationo Accessing with XmlHttpRequest DAY 2: ASP.NET AJAX • Introduction to Atlas• Introduction to ASP.NET AJAX• Dynamic Partial-Page Updates • Client-Side Network Callbacks • ASP.NET AJAX Features to an Existing o Web Applicationo Web Service Server Controls in ASP.NET AJAX • Adding the AJAX Server Controls to Visual Studio 2005 o Creating an AJAX enabled Web Siteo Adding the Server Controls to the Toolbox • Introducing the Script Manager Control o Using the Script Manager Designer Interface o Programming with the Script Manager • Introducing the Script Manager Proxy Control • Introducing the Update Panel Control o Using the Update Panel Designero Programming with the Update Panel• Introducing the Update Progress Control • Introducing the Timer Control The UpdatePanel Control • Introduction to the UpdatePanel Control • Multiple UpdatePanel Controls • Using the UpdatePanel Control with Data-Bound Controls • Using the UpdatePanel Control with Master Pages • Using the UpdatePanel Control with User Controls • Using the UpdatePanel Control with a Web Service • Customizing Error Handling for UpdatePanel Controls • Animating UpdatePanel Controls • Canceling an Asynchronous Postback • Working with PageRequestManager Events DAY 3: Introducing ASP.NET AJAX Extenders • Accordion• AlwaysVisibleControl• AutoComplete• CascadingDropDown• ConfirmButton• NumericUpDown• RoundedCorners• TextBoxWaterMark• Popup Control• Modal Popup• Collapsable • Draggable• FilteredTextBox• PasswordStrength Microsoft AJAX Library Client-side AJAX Programming • Introduction• Global Namespace • Sys • Sys.Net • Sys.Serialization • Sys.Services • Sys.UI • Sys.WebForms ASP.NET AJAX Extensibility • Introduction• Creating Custom ASP.NET AJAX Client Controls

Sunday, March 6, 2011

Debugging a DotNetNuke Installation

In this series of tutorials we demonstrate advanced debugging and troubleshooting techniques for DotNetNuke. This is an expert-level series that explores profiling, stack tracing, packet tracing, reverse compiling and more. We will also demonstrate how to troubleshoot performance problems caused by third party modules.

We will cover the following topics and tools:

* Part 1 - Introduction to Profilers
* Part 2 - Using SQL Profiler to Analyze Database Activity
* Part 3 - Using DotTrace to Analyze .NET Activity
* Part 4 - Using Managed Stack Explorer to View Stack Traces
* Part 5 - Using WireShark to wire-tap a Broken Module


Video 1 - Introduction to Profilers

* Introduction
* What are Profilers?
* Two Kinds of Profilers
* How to use Profilers to find Problems
* Two common types of performance problems
* Common Profiler Tools

Time Length: 2min 40secs

You need to Subscribe as a member of DNN Creative Magazine and Login to download this video tutorial.
Video 2 - SQL Profiler

* How to get SQL Profiler
* Running SQL Profiler
* Connecting to a Database Server
* Recreating the Performance Problem
* Understanding SQL Profiler's Data

Time Length: 4min 08secs
Video 3 - DotTrace

* How to get DotTrace
* Running DotTrace
* Profiling IIS
* A word of Warning
* Collecting Performance Data
* Understanding the Thread Tree and Call Tree
* Exploring the Call Tree
* Diagnosing the Performance Issue

Video 4 - Managed Stack Explorer

* Managed Stack Explorer vs DotTrace
* How to get Managed Stack Explorer
* Exploring Processes
* Exploring Threads
* Exploring Stack Traces
* Identifying the Problem

Video 5 - WireShark

* What is WireShark?
* How do you get a copy of it?
* Starting up WireShark
* The problem: A broken flash module
* Our first Wire-Tap
* Converting Packets to Streams
* Exploring the Flash Module's Stream
* Identifying the Flash Module's Problem
SOURCE:http://www.dnncreative.com/Tutorials/DNNTutorialsforAdvancedUsers/DotNetNukeDebugging/tabid/638/Default.aspx

DotNetNuke Portal Starter Kit

Overview

  • Fully dynamic web site allows for an unlimited number of Pages
  • Pages can contain an unlimited number of Content regions and Content types
  • Advanced Content Management enabled via a standard Web Browser
  • Build an online Community with robust Membership Management
  • Secure your Content using advanced Roles and Permissions
  • Multi-tenancy allows for multiple Sites to be hosted from a single installation

License

  • Unrestricted Open Source BSD license
  • FREE use in non-commercial and commercial environment

Extensibility

  • Modular architecture enables hundreds of third party plug-in Modules
  • Designer-friendly Skinning engine for total site customization
  • Multiple database support through Providers
  • More than 70 Language Packs to support International users

Support

  • More than 550,000 registered users since Dec 24, 2002
  • Maintained and supported by DotNetNuke Corporation

Dot Net Nuke (DNN)

Novel demands of the online global business environment for the last few years have initiated the business industry to adopt new technologies in form new software, open source frameworks, and content management systems to raise the opportunities for online business.

Dot Net Nuke (DNN) is open source content management system; initially developed in year 2002 and fully developed community for the last 6years supports it with strength of more than 575,000 registered users all over the world. Developed on most popular Microsoft ASP.NET technology and uses various databases for the storage of content. It is cheap to use and helps in reduction of total cost on development.
Few technical and non-technical advantages of DNN

* Its perfect content management system
* Free of cost availability and no licensing fees
* Full access to the source code to custom fit DNN to particular organizational needs
* DNN community building continually new features and functions
* Few important contents manageable by DNN are Text, Images, Documents, Links, Events, News, Banner ads, Threaded discussion forums, Email forms, Broadcast email, Site registration, RSS news feeds etc
* Modifications like graphic design and functionality
* Integration
* Able to support multiple websites from a single application installation
* Built in features provides extraordinary functionality
* Easy installation
* Management of site hosting, content management, security, web design and membership options
* Multi-language feature

Our dedicated services for DNN projects

Hiddenbrains.com has performed various offshore projects to prove its progressive approach towards new technologies for online web development. We have worked on several open source projects. Our research & development team always seeks opportunities to innovate and implement new technologies to satisfy our offshore clients. We are having decent presence for providing services in DNN customization, as we are group of experienced professionals. Projects were handling by team of experts to achieve perfect solution for each project. One of our successful projects is as under:
Fanous.com

Fanous.com was a jewelry shop website developed by hiddenbrains.com using DNN technology. Our development team had performed the project by implementation of its total features. Such a wonderful project covered all technical functionality of DNN. This website was able to handle the total functionality of multiple portals with single application.
There were three portals

* Fanous.com (it was front portal for the presentation of products and services for the customers)
* Fanous.biz (it was main administration for the total control of content on the website)
* Precision.net (it was administrative control for the employees of the company and other administrative controls)

Implementation of DNN features under this project according to business requirements of the client were

* Strong admin control over three portals
* Users at front hand able to choose the jewelry and order and can pay
* System settings
* Sub admin facilities and different roles given to other admin users

SOURCE:http://www.hiddenbrains.com/dotnet-nuke-development.html

Hire DotNetNuke Developers / Programmers

Dot Net Nuke (DNN) is open source content management system; initially developed in year 2002 and fully developed community for the last 6years supports it with strength of more than 575,000 registered users all over the world. Developed on most popular Microsoft ASP.NET technology and uses various databases for the storage of content. It is cheap to use and helps in reduction of total cost on development

DotNetNuke Content Management System is extensible and customizable through the use of skins and modules, and it can be used to create, deploy, and manage intranet, extranet, and web sites

DotNetNuke is an open source web application framework written in VB.NET for the ASP.NET framework.. DotNetNuke is designed for use on the Microsoft ASP.NET 2.0, 3.0, and 3.5 platforms using Visual Studio 2005, Visual Studio 2008, or Visual Web Developer.

ExpertsFromIndia can build you a DotNetNuke module customized to fit your business needs. Our developers have the skills to design and build a custom solution that follows your current business logic and integrate it into your DotNetNuke web site.

Our DotNetNuke Module Development services include:

  • Custom web application development
  • Business logic and data integration
  • Business process integration
  • 3rd party application integration
  • Professional DotNetNuke support

ExpertsFromIndia can provide everything from module planning to deployment, including training and support; our developers deliver solid web solutions on time and on budget

At Experts From India, we believe in great partnerships that delivers great results. Determining your business goals can help us not only in choosing the right application for you but also in delivering effective expertise.

Request a free quote to know more about customization and development of DotNetNuke.

DotNetNuke (DNN) Benefits

Sharepoint 2007 Benefits


Anyone in your company can edit content anywhere anytime Content Management for Web Content, Records and Documents
Used by 250,000+ organisations worldwide Powerful Workflow, Security and Content Policies
Easy to Deploy & Customise Source & Version Control
Built on ASP.NET and SQL Server Enterprise Search
Large number of 3rd party modules Built on ASP.NET and SQL Server

Hire DotNetNuke Developers

Experts From India offers you excellent services one of that is hire DotNetNuke developer. Our dedicated DotNetNuke developers are experts to provide you complete solution to your DotNetNuke application related services and needs. They are always at your service ensuring that your job will be done in time with the finest accuracy and available for urgent needs like patching or restoring your system after a crash. We look forward to assist you at anytime.

Cost to Hire Dedicated DotNetNuke developer

Our DotNetNuke developers/programmers are higly skilled with years of hands on experience. Their area of expertise includes ecommerce-shopping cart, dynamic website development, database management, project management, security and more. They are proficient in PHP, MySQL, JavaScript, VBScript, XML. A highly skiiled and experienced DotNetNuke developer cost you Starting From $5.0 Per Hour. For more details on DotNetNuke Dedicated developers pricing, Request a free Quote.

DotNetNuke Programmer Working Time

Experts From India’s Experts DotNetNuke Developers / Programmers works dedicatedly for you, 10 hours a day, 6 days a week. DotNetNuke Dedicated programmers will work under your timeframe and you can contact through MSN/Skype. In urgent case, you can directly call on developers mobile also. Experts From India always give 200% to clients with best solutions.

How DotNetNuke Developers/Programmers Works

After finalizing the DotNetNuke developers and project specification, your assigned DotNetNuke developer(s) can start ready to work within 24 hours.You can contact with your allocated DotNetNuke developer(s) through instant messenger and email.

Monitor Work:

  • Monitor project undertaken by your assigned DotNetNuke developer(s).
  • Project timetable and the outcome you expect from DotNetNuke programmer(s)
  • Follow-ups of development process for confirmation of project staying on right way
  • Interact hired DotNetNuke programmer(s) directly.
  • Experts From India’s management provides supervision to your developer(s)
  • Your offshore dedicated DotNetNuke developer will give services same as an in-house developer.

Payment Terms: The developer is going to work for you, on monthly contract hiring basis. Mode of payment will be Bank Wire Transfer, Credit Card or Paypal.

Get free Quote for detailed proposal for your DotNetNuke Applicationt.


SOURCE:http://www.expertsfromindia.com/dotnet-nuke-development.htm

How to make money from your DotNetNuke website

There are several ways in which you can monetize your DotNetNuke website. In this article we are going to discuss the methods that are available with the default modules in DotNetNuke.
These methods can be used with any type of website from a static to a dynamic website. The advantage of using DNN is the flexibility and ease of use for configuring and tracking.
Advertising
The first and easiest method for a web master to implement on their website is to enable advertising.

There are several advertising methods that you can implement and we will discuss each of them in turn.

Text/HTML
DotNetNuke provides an easy solution for combining all of the various advertising methods through the use of the Banners module. The Banners module allows you to rotate advertisements on each page load, while also allowing you to track the number of click-throughs for each advertisement.

The banners module can display all of the advertising types that are mentioned below; it is not just limited to displaying banner image advertisements.

You can learn how to use and configure the banners module in this tutorial.
Payment Schemes
Before we discuss the various advertising methods, we need to explain the payment schemes that the advertising methods tend to use.
Pay-Per-Impression
Your payments are based on how many impressions you display an advertisers’ banner for. An impression is a page view of the banner by a visitor to your website. Typically payments are calculated on a Cost-Per-Thousand impressions (CPM) basis ie. $5 CPM refers to $5 for 1000 displays of the banner. The higher the traffic on your website the more impressions you can generate and therefore the more advertisers you can display and create more income.

On very high traffic websites some webmasters use a pay per month method where you pay a set amount to advertise on the website for the month with a guaranteed minimum number of impressions.
Pay-Per-Click
You receive a payment each time an advertisement is clicked on. Payments for this can vary from a few cents to several dollars per click. The payment level depends on the niche and the consumer demand for the niche. Other factors that you need to take into consideration are your conversion level ie. How many times is an advertisement displayed before it receives a click? If you can generate a high CTR (Click-Through-Rate) and a high level of traffic you can generate a good source of income even from low paying pay-per-click advertisements.
Pay-Per-Lead
Here you receive a payment for any leads you send to the advertiser. The visitor to the advertisers’ website may have to supply their email address and sign up to an email newsletter before you receive a payment.

You need to bear in mind that this may involve two steps. The first is the conversion of the visitor clicking on the advertisement on your website and the second is the conversion of the visitor on the advertisers’ website signing up to the newsletter.

This type of income may receive fewer conversions than pay per click, but the payments per lead tend to be higher, so you can potentially earn a higher income than Pay-Per-Click.
Pay-Per-Sale
Potentially this method has the lowest conversion rate, but if the advertisers are carefully targeted to the niche topic of your website you could receive a large income. An example of this is the affiliate marketers that earn millions each year from selling other peoples products. In this method you only receive a payment when a visitor to your website purchases a product from your advertiser.
Payments
If you are implementing Pay-Per-Impressions advertising you can request payment for the advertisement up front before you allow the advertisement to be displayed on your website. For all of the other methods, payment tends to be held back until you have accumulated on average $100 in clicks / leads / sales. Also make sure that you double check how soon they make a payment after you reach the minimum payment level. Some programmes may wait 30 days until they pay you. This is important to check for the cashflow of your business.
Tip
If there is one tip I can pass on it is this. Test the advertisement method for a month and if it is not making enough money, analyze why:

* Do you need to increase the conversion rate?
* Do you need to increase the traffic?
* Is the advertisement suitable for your niche market?

Several years ago, I learnt a lesson the hard way. In the first year of creating a website directory, all of the advertising was based on the pay per sale method. The traffic on the website was high, the click through rate on the banner ads was good, but the sale conversion was very low (the products were not close enough to my niche). I made less than $100 in a year which I never received because the minimum payment was $100. I then switched to pay-per-click and pay-per-impression and made several hundred dollars in the first month! I realised I had literally lost thousands of dollars over that year from not testing and analyzing the advertising methods.

The DotNetNuke banners module allows you to rotate between ads that use the various payment methods, so you can easily setup and analyse the conversion rate of several advertising methods at once and avoid the mistakes I made.

As a starting point I would suggest that you try each of the payment methods and analyze which ones provide you with the most income for your website.

Note: I have had successes with Pay-Per-Sale; you just need to ensure that the advertisements are very close to your website market niche and that the visitors to your website are willing to buy products.
Advertisement Methods
You have several options available for advertising within your DotNetNuke portal. They can be split into two groups, image based advertisements and text based advertisements.

The DotNetNuke Banners module advantage
The DotNetNuke banners module can display a combination of these different advertisement methods at the same time and rotate between the various advertisements.

For instance if you have an advertising space available on the right hand column of your pages, you could display within the same column, a text ad, a Google Adsense ad and another text ad. With the next refresh of the page this could switch to a skyscraper ad and two text ads. You can learn these advanced configuration techniques in this tutorial.

This has the advantage that the position of the advertisements and the type of advertisement is always changing, which should help to grab the attention of a visitor and avoid 'ad blindness.'

Email Newsletter advertisements
If you send a regular newsletter, you could include advertisements within the email. But, make sure that your recipients have opted-in to the email as they could become very annoyed if you send emails trying to sell them products. Here you can learn about the Email Newsletters module.
Programmes
We have covered the various payment methods and advertising methods, the next step is to find advertisers for your website and this is actually not as hard as it may sound.
DIY - Do It Yourself
Probably the first advertising method to appear on the internet and the hardest if you are just launching your website. This involves approaching companies that provide products or services that complement the niche of your website. In most cases you will need to provide a PDF document outlining the cost structure for advertising, the niche market, and the number of visitors / page views you receive on average each month for your website.

Make sure you include a ‘Terms of Use’ document in-case any problems occur with the advertiser and also create a page within your website informing visitors that you offer advertising. (You could combine this with a banner advertisement that states ‘Would you like to advertise here?’).

If your website is already established with a high amount of traffic, you may find that advertisers contact you to advertise on your website.

Payment method: Pay-Per-Impression and Pay-Per-Month are typical for this type of advertising.

Advertising method: All banner types, text advertisements and even email newsletter advertisements are suitable for the DIY approach. You can charge varying amounts for the banner types and position of the banner on the page.
Advertisements for content
This is one of the popular and easiest methods for creating an income from your website. It also requires no maintenance as everything is automated.

The most popular programme for this is Google Adsense. All you have to do is sign up to Google Adsense and add the short Javascript code to your DotNetNuke Banners module.

This will display advertisements directly related to the content of your page meaning you have very specific advertisements related to the niche topic of your website.

Payment method: Pay-Per-Click

Advertising method: Text ads are mainly used, but banner image ads can also be displayed. You have the option for configuring the layout of the text ads into various banner sizes.

I would recommend you view An Introduction to Google Adsense followed by this video tutorial, which walks you through how to incorporate Adsense with DotNetNuke. This is recommended over just using the Banners module for displaying Google Ads to increase your click-through-rate and profits.

Here is a selection of programmes that are worth experimenting with:

BidVertiser

Yahoo Network
Affiliate advertising
Here you operate as an affiliate to another company. In most cases you register with the company as an affiliate through their website. Some affiliate programmes require that you have a website and sometimes a minimum amount of traffic. The company will decide whether or not to approve or reject your application as an affiliate; generally this is based on the content of your website. Once approved, you will have access to the affiliates section of their website which will provide you with:

Your affiliate id – Place this id in the advertisement URL link. This id is used to track the click-throughs from your website.

Advertisements – Banner ads, Text ads, Email content etc. If it is a good affiliate programme they should supply you with a large selection of advertising content to choose from. You can place these advertisements in the DotNetNuke Banners module along with your affiliate link.

Tracking Reports and Stats – A good affiliate programme will allow you to view the number of click-throughs / conversions / sales / leads that you have made along with the amount of money you have earned.

Extras – Support, tips, help, forum, pricing structure benefits for users that generate a high number of sales etc. All of these help to provide a good affiliate programme.

Payment method: Usually Cost-Per-Sale and Cost-Per-Lead, some programmes will provide Cost-Per-Click.

Advertising method: All methods can be used, image, text and email advertisements. You can also incorporate links to affiliate programmes directly within the content of your website. For instance, if you are writing a book review, you could include an affiliate link to amazon.com for the visitor of your website to buy the book.

Use Visual Web Developer Express (VWD) with DotNetNuke!

  • Not possible you say! DotNetNuke uses a very complex n-tier framework which will not work with Visual Web Developer Express(VWD). You're right, but you don't need it to. That's the point of DotNetNuke. Think of DotNetNuke as a souped-up Windows SharePoint Services (WSS). With the SmartDNNModule you can use any .net language VB.Net, C#.Net, C++.Net, J# .Net user control, no special hooks or programming just need the SmartDNNModule.

    Not possible you say! DotNetNuke uses a very complex n-tier framework which will not work with Visual Web Developer Express(VWD). You're right, but you don't need it to. That's the point of DotNetNuke. Think of DotNetNuke as a souped-up Windows SharePoint Services (WSS). With the SmartDNNModule you can use any .net language VB.Net, C#.Net, C++.Net, J# .Net user control, no special hooks or programming just need the SmartDNNModule.

    In this article I am going to show you how to use VWD (also same steps for VS) to build a user control and load it into a DotNetNuke website.

    Programmers work smarter not harder!

    Resources:

    What is DotNetNuke?

    Visual Web Developer Download - Free development environment available from the Microsoft Website.

    Why is DotNetNuke so popular? (not my site just found it on google)

    * DNN also includes Windows,forms,or ldap authentication
    * Advanced Security/roles/membership framework
    * Skinning….thousands ready to buy CHEAP from snowcovered.com
    * DNN 4 Supports ASP.Net 1.1 and 2.0 usercontrols
    * A huge community of developers and experts

    What is SmartDNNModule?

    * It is a user control wrapper that is used to create DNN modules from any user control.

    Article:

    Basic assumption; that you know how to use Visual Web Developer Express or Visual Studio.

    Step1. Create a user control.

    * In Visual Web Developer Express create a new website
    * File >>New File>>Web User Control (see image)
    * Click add

Step 2.

Add controls and or any programming to your user control:

Step 3.

Create your “UserControls” folder in your dotnetnuke root folder hint your UserControls folder should be at the same level as the bin folder:

Step 4.

Put the .ascx and .ascx.resx files in the usercontrols folder (in ASP.NET 2.0 just the .ascx):

Step 5.

Put the .dll into the bin folder (Visual Studio only – VWD is inline code skip this step)

Step 6.

Upload SmartDNNModule.zip into your DNN portal and onto a page then type in the name of your usercontrol(s) – remember in DNN you can have a view and edit controls or just a view. In this sample we just have a view control.

Click Create Module: and wait for the page to finish loading then click on the page link to refresh the page:

That’s it! You can create any user control with any .Net compliant language and load it into a DNN portal installation.


SOURCE:http://www.wwwcoder.com/main/parentid/224/site/6108/68/default.aspx

DotNetNuke outstanding issue stats for the 4.6.0 release

Hi

My name is Alex Shirley (aka NukeAlexS) and if you've logged any issues this year in our bug tracker software Gemini, then the chances that I would have been your first point of contact. Right now you are my first point of contact because this is my first blog on this site. Anyway, it's my primary job when you log your issue in Gemini to validate it, decide where best it should be directed at, and how important it is. Once it reaches the core team they re-review what I did (often I get it wrong), and then they attempt the real work of getting the issue resolved.

Back in 2006 I looked at DNN and I felt that whilst it was a great application and fit for purpose (otherwise I wouldn't be using it), there were a large number of outstanding issues that I perceived were not being looked at. I just could not understand why really obvious issues were not being dealt with at all. In the end I posted a strong complaint in the forums, and rather the receive a message of complete indifference, or somebody telling me to stop whinging, I was asked by Shawn Mehaffie to join the QA team and help sort the problem out. I was rather taken aback to be honest, flattered, and in the end I just had to accept.

Moving on... it has been mine and the QA teams priority clean up the outstanding issues in the Gemini core and public projects, so the rest of the core team can do it's job efficiently, it has been a tall order, and right now I think we have a reasonable (but not perfect) picture of what is going on, so it's time to report in.

So it's my pleasure to publish some Dotnetnuke outstanding issue stats for the 4.6.0 release, and I hope this plays a part in making our open source framework more transparent to all of the DNN community. Of course these stats are always available on http://support.dotnetnuke.com, it's just that it's been very much hidden. I will be showing you how to monitor the situation yourself in realtime in a future blog entry, but right now here it is for your consumption:
Outstanding issues in DNN Core Framework 4.6.0 (at launch)

Show Stopper


Major


Minor


Trivial


Total

PDF Report
Bugs


1

73

104

34

212

Tasks


0

8

34

26

68

Enhancements


1

100

261

199

561

New Features


0

21

55

27

103

Total

2

202

454

286

944

Click Here

Note that in order to give you a more realistic picture, issues set as require more info are not included in the above statistics. There are 24 require more info issues at present. Also note this is just statistics for the core framework application, sub-project stats are not included .
The PDF report contains detail on the actual issues involved.

As always we aim to get the number of issues down over the course of the next few releases, especially the bugs. Remember though that more often then not, as soon as one issue is fixed then another one is logged - the project never remains static! So if you are an ASP.NET developer perhaps you can help us by submitting code that will help put to bed our outstanding issues (more about how to do this will be in a future blog, but in a nutshell all you need to do is search for an issue in gemini and leave a comment that includes your code).

Please also realise that these are just figures, and in reality we don't actually know the full picture until the issue is resolved. So if you really want to get an idea of just how stable Dotnetnuke is, use it! Remember this is a heavyweight open source framework application, designed to be flexible, that is used by a heck of a lot of people around the world.

Finally I'd like to sign off by saying that 4.6.0 is just one heck of a release, I know people have worked really hard on this one, and our main body of core team members have been extremely active. They all deserve our thanks, and for me it's the best release yet.. so thanks team!