Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

23
Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC

Transcript of Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

Page 1: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

Integrating CFML with ASP.NET

Vince BonfantiPresident

New Atlanta Communications, LLC

Page 2: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

Introduction

• Vince Bonfanti

• President and co-founder of New Atlanta– ServletExec, Java Servlet/JSP engine (1997)

– JTurbo, JDBC driver for MS SQL Server (1998)

– BlueDragon, CFML/JSP server (2002)• Soon to be .NET-based

[email protected]– Mention CFUN on subject or message body

Page 3: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

Topics

• What is the .NET Framework?– compare/contrast to Java

• What is ASP.NET?

• What is BlueDragon for .NET?

• How do we integrate CFML pages into ASP.NET web applications?

• Why deploy CFML on .NET servers?

Page 4: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

.NET Framework Overview

• The new way to program on Windows, replacing C/C++ and Visual Basic

• Installed as a standard component of Windows 2003 Server, can be installed on Window NT/2000/XP

• Primarily useful for server-based applications, can also be used for client (desktop)

Page 5: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

.NET Framework Goals

• Object-oriented, type-safe, garbage-collected, secure, etc.– Increases programmer productivity and

improves application reliability, especially for complex server-based enterprise applications

• Similar goals as Java (without write-once-run-anywhere)– Similar methods to achieve those goals

Page 6: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

.NET Framework Components

• Common Language Runtime (CLR)– like Java Virtual Machine (VM)

• Microsoft Intermediate Language (IL)– like Java byte code– .dll (assemblies) or .exe versus .class or .jar

• .NET Framework Class Libraries (FCL)– like Java class libraries

• Multiple programming languages– C#, Visual Basic.NET, Managed C++, J#

Page 7: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

.NET versus Java

C# VB.NET J#…

IL (CLR)

Windows

Windows Solaris Linux…

byte code (VM)

Java

WebLogic WebSphere JRun…

• single platform• single vendor• higher platform integration• lower complexity• lower cost • multi-platform, multi-vendor

• lower platform integration• higher complexity, higher cost

Page 8: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

ASP.NET Overview

• The way to write web applications and web services in .NET

• Can use any .NET programming language

• Only runs on Microsoft IIS web server• Pages are compiled (like JSP)• Unique concepts

– Event-driven versus top-to-bottom execution– Code-behind files to separate logic from UI– Controls are the key component technology

Page 9: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

ASP.NET Web Applications

• An IIS web site or virtual directory• .aspx web pages or .asmx web services• Optional components

– One global.asax file (like Application.cfm)– One or more web.config configuration files

• Inherits from machine.config

– User controls in .ascx files– A /bin directory for assemblies (also GAC)

• HttpHandlers and HttpModules

– Web content files (.htm, .css, .gif, etc.)

Page 10: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

ASP.NET Demo

• Simple web page (hello.aspx)

• Simple web server (hello.asmx)

• Control and event handling (declarative.aspx)

• Control and event handling (codebehind.aspx, codebehind.vb)

Page 11: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

hello.aspx<%@ Page Language="vb" %><html><head>

<title>Simple ASP.NET Page</title><script runat="server">Sub SayHello()

Response.Write( "Hello, World!" )End Sub</script>

</head><body><% SayHello %></body></html>

Page 12: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

hello.asmx<%@ WebService Language="vb" Class="Hello" %>

Imports SystemImports System.Web.Services

Public Class Hello : Inherits WebService<WebMethod()> Public Function SayHello() As String

Return( "Hello, World!" )End Function

End Class

Page 13: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

declarative.aspx<%@ Page Language="vb" %><html><head>

<title>ASP.NET Declarative Example</title><script runat="server">Sub Page_Load( Sender As Object, e As EventArgs )

Message.Text = "Hello, World!"End Sub</script>

</head><body><form runat="server">

<asp:Label id="Message" runat="server"/></form></body></html>

Page 14: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

codebehind.aspx

<%@ Page Language="vb" Src="codebehind.vb"

Inherits="example.CodeBehind" %><html><head>

<title>ASP.NET CodeBehind Example</title></head><body><form runat="server">

<asp:Label id="Message" runat="server"/></form></body></html>

Page 15: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

codebehind.vbImports SystemImports System.WebImports System.Web.UIImports System.Web.UI.WebControls

Namespace example

Public Class CodeBehind : Inherits Page

Protected Message As Label

Protected Sub Page_Load( Sender As Object, e As EventArgs ) Message.Text = "Hello, World!" End Sub

End Class

End Namespace

Page 16: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

web.config

• Used to configure ASP.NET applications– Application initialization parameters– Authentication and authorization– Compilation defaults– Session data storage– Debug and trace settings

• Can be multiple web.config files– One per directory, inherit from parents– All inherit from machine.config

Page 17: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

web.config<?xml version="1.0" encoding="utf-8" ?><configuration> <system.web> <compilation defaultLanguage="vb" debug="false"/>

<sessionState mode="InProc“ stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;user id=sa;password=" cookieless="false" timeout="20" />

<httpHandlers> <add verb="*" path="*.cfm" type="com.newatlanta.bluedragon.HttpHandler,BlueDragon"/> </httpHandlers> </system.web></configuration>

Page 18: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

HttpHandler

• Custom (user-defined) components (.NET objects) that process HTTP requests

• Can be written in any .NET language

• Requests are mapped to HttpHandlers via directives in web.config

• .aspx pages are compiled to HttpHandlers

• HttpHandlers are like Java servlets– JSP pages are compiled to Java servlets

Page 19: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

HttpHandler Example

using System.Web;

namespace Example{

public class HelloHttpHandler : IHttpHandler{

public void ProcessRequest( HttpContext context )

{ context.Response.Write( “Hello, World!” );}

}}

Page 20: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

BlueDragon for .NET

• BlueDragon.NET is a CFML runtime that is implemented as an HttpHandler

• The BlueDragon.dll assembly can be placed either in the ASP.NET application /bin directory, or the GAC

• Configured via web.config or machine.config to route *.cfm page requests to BlueDragon.dll

Page 21: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

Integrating CFML into ASP.NET

• Use BlueDragon.NET to deploy CFML pages in ASP.NET web applications, side-by-side with .aspx pages and .asmx web services

• Share Application, Session, and Request scope variables

• Use CFOBJECT to access .NET objects– Use ASP.NET controls in CFML pages

• Write CFX tags in any .NET language

Page 22: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

BlueDragon.NET Demo

• BlueDragon.NET configuration

• Hello.cfm

• BlueDragon admin console

• ASP.NET calendar control

Page 23: Integrating CFML with ASP.NET Vince Bonfanti President New Atlanta Communications, LLC.

Why CFML on .NET?

• Performance– .NET CLR versus Java VM– ADO.NET versus JDBC

• Scalability: take advantage of Windows 2003 Server clustering

• Native Windows platform integration– Fast, reliable COM integration

• Migration to ASP.NET• Another platform alternative for ISVs