Download Integration CFML with ASP.NET

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

URL redirection wikipedia , lookup

Transcript
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
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?
.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)
.NET Framework Goals
• Object-oriented, type-safe, garbagecollected, secure, etc.
– Increases programmer productivity and
improves application reliability, especially
for complex server-based enterprise
applications
• Similar goals as Java (without writeonce-run-anywhere)
– Similar methods to achieve those goals
.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#
.NET versus Java
C#
VB.NET
…
J#
Java
byte code (VM)
IL (CLR)
Windows
• single platform
• single vendor
• higher platform integration
• lower complexity
• lower cost
WebLogic
Windows
WebSphere
Solaris
…
…
JRun
Linux
• multi-platform, multi-vendor
• lower platform integration
• higher complexity, higher cost
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
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.)
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)
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>
hello.asmx
<%@ WebService Language="vb" Class="Hello" %>
Imports System
Imports System.Web.Services
Public Class Hello : Inherits WebService
<WebMethod()> Public Function SayHello() As String
Return( "Hello, World!" )
End Function
End Class
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>
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>
codebehind.vb
Imports
Imports
Imports
Imports
System
System.Web
System.Web.UI
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
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
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>
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
HttpHandler Example
using System.Web;
namespace Example
{
public class HelloHttpHandler : IHttpHandler
{
public void ProcessRequest( HttpContext context )
{
context.Response.Write( “Hello, World!” );
}
}
}
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
Integrating CFML into ASP.NET
• Use BlueDragon.NET to deploy CFML
pages in ASP.NET web applications, sideby-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
BlueDragon.NET Demo
•
•
•
•
BlueDragon.NET configuration
Hello.cfm
BlueDragon admin console
ASP.NET calendar control
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