creating simple programming with asp.net 김순근.netxpert solution consultant...
TRANSCRIPT
Creating simple Creating simple programming with ASP.NETprogramming with ASP.NET
김순근김순근.netXpert Solution Consultant.netXpert Solution [email protected]://www.noenemy.net
AgendaAgenda
1.1. ..NET? .NET Framework!!NET? .NET Framework!!• CLR, MSIL, JIT Compiler…CLR, MSIL, JIT Compiler…
2.2. ASP vs ASP.NETASP vs ASP.NET3.3. ASP.NET PagesASP.NET Pages
• Web FormWeb Form• Server ControlsServer Controls
4.4. ASP.NET InfrastructureASP.NET Infrastructure• 상태관리상태관리 , , Configuration Configuration • 배포배포 , , 인증과 권한인증과 권한
5.5. ASP.NET Web ServicesASP.NET Web Services
.NET?.NET?
.NET Framework!!.NET Framework!! 11
Windows 2000 DNAWindows 2000 DNA
VBScriptVBScriptVBScriptVBScript JavaScriptJavaScriptJavaScriptJavaScript
C/C++C/C++C/C++C/C++Visual BasicVisual BasicVisual BasicVisual Basic
Internet Information ServerInternet Information ServerInternet Information ServerInternet Information Server
Active Server PagesActive Server Pages
COM+ ComponentsCOM+ Components
SQL ServerSQL Server
HTTPHTTP
Windows DNA Windows DNA 와 와 ..netnet
전자상거래Inventory Inventory
물품주문 수행 물품주문 수행
SQL Server, Oracle, DB2 SQL Server, Oracle, DB2
B2B무역거래
공급자 공급자 A A
FirewallFirewall 공급자 공급자 B B
Windows DNA AppWindows DNA App
Rich and Rich and ReachReach
다양한 클라이언트 환경
웹 서비스로 웹 서비스로 제공제공
..NETNET 과 과 ..NET FrameworkNET Framework
Windows (CE, ME, 2000, and .NET)Windows (CE, ME, 2000, and .NET)
Visual Studio.NET
.NET Enterprise
Servers
BuildingBlock
Services
.NETFramework
Base Classes
Data & XML
Win Forms
Common Language Runtime
ASP.NET
Common Language Runtime ( Common Language Runtime ( CLR )CLR )
플랫폼 종속성 탈피플랫폼 종속성 탈피 Processor Processor 별 별 CLR CLR 제공제공 X86 , 64bit, Pocket PC, LINUX ? , UNIX ?X86 , 64bit, Pocket PC, LINUX ? , UNIX ?
언어통합언어통합 ((Language Integration)Language Integration) 진정한 언어통합진정한 언어통합 , , 상호 언어간 상호 언어간 OOP OOP 적 통합 가능적 통합 가능 Common Type System(CTS)Common Type System(CTS) Common Language Specification(CLS)Common Language Specification(CLS)
효과적효과적 자원관리자원관리 Garbage Collection(GC)Garbage Collection(GC)
Common Language Runtime ( Common Language Runtime ( CLR )CLR )
디버깅의 효율성 증대디버깅의 효율성 증대 언어통합으로 인한 일관성 있는 디버깅 가능언어통합으로 인한 일관성 있는 디버깅 가능 Stack-Walking Stack-Walking 을 통한 용이한 버그 위치 파악을 통한 용이한 버그 위치 파악
일관성 있는 에러처리일관성 있는 에러처리 Win32 Win32 형태 형태 / / HRESULT HRESULT 형태형태→ → Exception NotificationException Notification
배포의 용이성배포의 용이성 레지스트리 레지스트리 / / DLL Hell → Xcopy InstallationDLL Hell → Xcopy Installation
MSIL & JIT CompilerMSIL & JIT Compiler
MSIL(Microsoft Intermediate Language)MSIL(Microsoft Intermediate Language) Language CompilerLanguage Compiler 에 의해 에 의해 Language Language
Specification Specification 에 맞추어 변환된 형태의 중계언어에 맞추어 변환된 형태의 중계언어 PE(PotablePE(Potable Executable) Executable) 파일형태 파일형태 ( .( .EXE / .DLL)EXE / .DLL) Self Description (Meta Data : Assembly Self Description (Meta Data : Assembly
Manifest )Manifest ) IL DASM ( ILDASM.EXE )IL DASM ( ILDASM.EXE )
JIT(Just-In-Time) CompilerJIT(Just-In-Time) Compiler CLR CLR 이 프로그램을 수행할 수 있도록 이 프로그램을 수행할 수 있도록 CLRCLR 을 위한 을 위한
원시코드로의 원시코드로의 compile compile 수행수행 Processor Processor 별 별 JIT CompilerJIT Compiler
MSIL
MSIL & JIT CompilerMSIL & JIT Compiler
Source Code
Language Compiler
Compilation
Before installation or the first time each method is called
Execution
JIT Compiler
NativeCode
Code
Metadata
Execution ModelExecution Model
VBVB VCVC C#C# ScriptScript
ILIL
““Econo”-JITEcono”-JITCompilerCompiler
Standard JITStandard JITCompilerCompiler
NativeNativeCodeCode
Common Language RuntimeCommon Language Runtime
Opt JITOpt JITCompilerCompiler
Compiled by Language CompilerCompiled by Language Compiler
ExecutionExecution
Base Class Library
ADO.NET XML
ASP.NET Windows
..NET Framework NamespaceNET Framework Namespace
System
Globalization
Diagnostics
Configuration
Collections
Resources
Reflection
Net
IO
Threading
Text
ServiceProcess
Security RuntimeInteropServices
Remoting
Serialization
System.Data System.Xml
SqlClient
Common
SQLTypes
OleDb
XPath
XSLT Serialization
System.Web
Configuration SessionState
Caching Security
ServicesDescription
Discovery
Protocols
UIHtmlControls
WebControls
System.Drawing
Imaging
Drawing2D
Text
Printing
System.Windows
Forms Design
ASP vs ASP.NETASP vs ASP.NET 22
Strength of ASPStrength of ASP
쉽고 강력한 웹 어플리케이션 개발쉽고 강력한 웹 어플리케이션 개발
HTML / Server Side Script Mixed featureHTML / Server Side Script Mixed feature
컴파일 필요 없음컴파일 필요 없음
메모장을 통한 스크립트 코딩만으로 실행메모장을 통한 스크립트 코딩만으로 실행
COM COM 객체를 통한 확장성객체를 통한 확장성
Server Side Component , ADOServer Side Component , ADO
Weakness of ASPWeakness of ASP
비구조적 개발언어비구조적 개발언어 스파게티 가락 코딩스파게티 가락 코딩 , , 코드의 난독성코드의 난독성
스크립트 언어의 한계스크립트 언어의 한계 Early Binding Early Binding 지원 불가능지원 불가능 , , InterpretingInterpreting
Server Component Server Component 관리문제관리문제
State ManagementState Management
Session Session 의 문제점 – 의 문제점 – Web Farm Web Farm 환경에서의 한계환경에서의 한계
Page State Page State 유지유지
웹 브라우저의 제한 웹 브라우저의 제한 – 호환성 유지 어려움– 호환성 유지 어려움
ASP.NET ASP.NET 특징특징
체계적인 프로그래밍 구조체계적인 프로그래밍 구조
언어 독립성언어 독립성
스크립트 언어가 아닌 스크립트 언어가 아닌 CLR CLR 을 지원하는 모든 언어 을 지원하는 모든 언어
사용가능사용가능
CLRCLR 이 지원하는 모든 플랫폼 하에서 구동 가능이 지원하는 모든 플랫폼 하에서 구동 가능 LINUX, UNIX LINUX, UNIX 플랫폼 하에서 구동가능성플랫폼 하에서 구동가능성
코드와 인터페이스의 분리코드와 인터페이스의 분리
유지보수의 편리성유지보수의 편리성 , , 어플리케이션의 확장성어플리케이션의 확장성
Easy Deployment – just xcopy!Easy Deployment – just xcopy!
ASP.NET ASP.NET 특징특징
다수의 클라이언트 지원다수의 클라이언트 지원
Explorer / Netscape / Mac / Pocket PC /Explorer / Netscape / Mac / Pocket PC /
Mobile phone – “Mobile phone – “ 알아서 렌더링한다알아서 렌더링한다 !”!”
ASP.NET ASP.NET 특징특징 ..NET NET 플랫폼과의 완벽한 통합플랫폼과의 완벽한 통합
WebForm Class WebForm Class 사용 사용 성능향상성능향상
Compiled PageCompiled Page Garbage Collection(GC)Garbage Collection(GC)
개발 생산성 향상개발 생산성 향상 개발툴 개발툴 ( ( VS .NET)VS .NET) OOPOOP 에 의한 모듈화 에 의한 모듈화 ProgrammingProgramming
Cookie-less SessionCookie-less Session
PC Magazine Nile Application TestPC Magazine Nile Application Test
24002400
12001200
16001600
800800
400400
28002800
20002000
초당 서비스 가능 페이지 수초당 서비스 가능 페이지 수8 8 CPUCPU
4 CPU4 CPU
2 CPU2 CPU
Microsoft Microsoft ASP ASP
Microsoft Microsoft ASP.NETASP.NET
1989
1154
2781
330
748637
Hello, Hello, ASP.NET!ASP.NET!
ASP.NET Platform ASP.NET Platform ArchitectureArchitecture
PagesPages ServicesServices
Application Service(Infrastructure)Application Service(Infrastructure)
ASP.NET PagesASP.NET Pages 33
ASP.NET PagesASP.NET Pages
Web Form ControlWeb Form Control Intrinsic Controls ( Intrinsic Controls ( 기본컨트롤 기본컨트롤 )) List ControlsList Controls Rich ControlsRich Controls Validation ControlValidation Control
PageletPagelet Cache – Data Cache / Output CacheCache – Data Cache / Output Cache DebuggerDebugger State ManagementState Management
ASP.NET Page FrameworkASP.NET Page Framework Control-based, event Control-based, event 기반의 실행모델기반의 실행모델
““Web Web 의 의 VB”VB” ASP ASP 시절보다 휠씬 적어진 코딩시절보다 휠씬 적어진 코딩 완벽한 완벽한 Encapsulation Encapsulation 지원지원
Compiled languagesCompiled languages VB, C#, Jscript, ………VB, C#, Jscript, ……… Executed via CLR as native codeExecuted via CLR as native code
ASP.NET ASP.NET 페이지는 “페이지는 “ ..ASPX” ASPX” 확장자를 확장자를 사용한다사용한다 IIS IIS 상에서 현재의 상에서 현재의 ASP application ASP application 들과 함께 구동 들과 함께 구동
된다된다
ASP.ASP.NETNET Execution ModelExecution Model
Server Controls (1)Server Controls (1)
HTML Server ControlsHTML Server Controls Html ElementHtml Element 와 와 1:1 1:1 맵핑맵핑
Web Form ControlsWeb Form Controls Intrinsic Controls ( Intrinsic Controls ( 기본컨트롤 기본컨트롤 ))
Label, Textbox, Label, Textbox, Image, Checkbox,Image, Checkbox, Radiobutton, Button, Linkbutton,Radiobutton, Button, Linkbutton, Imagebutton, Imagebutton, Hyperlink, Hyperlink, Table, TableCell, TableRow, Table, TableCell, TableRow, PanelPanel
File Upload SampleFile Upload Sample
Server Controls (2)Server Controls (2)
Web Form ControlsWeb Form Controls Validation Controls – Validation Controls – 유효성검사 컨트롤유효성검사 컨트롤
RequiredFieldValidator - RequiredFieldValidator - 필수입력사항필수입력사항 ComparedValidator – ComparedValidator – 값 비교값 비교 RangeValidator – RangeValidator – 값의 범위값의 범위 RegularExpressionValidator - RegularExpressionValidator - 정규식정규식 CustomValidator – CustomValidator – 사용자정의 유효성 검사사용자정의 유효성 검사 ValidationSummary – ValidationSummary – 유효성 검사 결과 요약유효성 검사 결과 요약
회원가입 페이지회원가입 페이지
Server Controls (3)Server Controls (3)
Web Form ControlsWeb Form Controls Rich ControlsRich Controls
AdRotator ControlAdRotator Control Calendar ControlCalendar Control
ListControlsListControls Repeater ControlRepeater Control DataList ControlDataList Control DataGrid ControlDataGrid Control
Calendar Controls &Calendar Controls &DataGrid ControlsDataGrid Controls
Tracing Tracing 지원지원
페이지 실행간의 상태 정보를 제공한다페이지 실행간의 상태 정보를 제공한다 Method timings, control information, Method timings, control information,
headers, server variablesheaders, server variables 실행간에 사용자 정의 출력을 보여준다실행간에 사용자 정의 출력을 보여준다
장님 코끼리 만지기 식 디버깅 – 장님 코끼리 만지기 식 디버깅 – Response.Write Response.Write 사용사용
Trace.WriteTrace.Write – – 일반 메시지 출력시 사용일반 메시지 출력시 사용 Trace.WarnTrace.Warn – – 빨간색으로 메시지 출력빨간색으로 메시지 출력
Tracing Tracing 사용하기사용하기
Caching SupportCaching Support
Full page output caching Full page output caching Vary by params, language, user-agentVary by params, language, user-agent
Fragment Caching Fragment Caching 페이지의 일부 – 페이지의 일부 – Pagelet Pagelet 에 대한 캐시지원에 대한 캐시지원
Extensible Cache APIExtensible Cache API 개발자가 임의로 개발자가 임의로 Cache Cache 에 에 Data(Object)Data(Object) 를 를
저장할 수 있는 기능을 제공저장할 수 있는 기능을 제공 다중의 다중의 expiration policies expiration policies 지원 지원 - -
DependencyDependency
ASP.NET ASP.NET InfrastructureInfrastructure 44
ASP.NET InfrastructureASP.NET Infrastructure
Global.asaxGlobal.asax Session_OnStart , OnEnd / Session_OnStart , OnEnd /
Application_OnStart, OnEndApplication_OnStart, OnEnd☞ ☞ 보다 다양한 이벤트 제공보다 다양한 이벤트 제공
web.configweb.config IIS Meta Base web.config XML File☞IIS Meta Base web.config XML File☞ 보다 세밀한 제어 가능보다 세밀한 제어 가능
DeploymentDeployment – XCopy Installation – XCopy Installation 보안보안
Scale-Out Web ArchitectureScale-Out Web Architecture
Session Session 드디어 드디어 Web Farm Web Farm 환경을 지원하환경을 지원하다다 !! 드디어 드디어 Per Server Per Server 라는 제한을 극복하게 됨라는 제한을 극복하게 됨 한대의 한대의 State State 서버는 다중의 서버는 다중의 App Server App Server 를 를
지원한다지원한다 다양한 다양한 Session State Provider Session State Provider 제공제공
InProcInProc OutProc - State server (OutProc - State server ( 로컬 로컬 or or 원격원격 )) SQL ServerSQL Server
ASPNET_STATE
INETINFO
ASPNET_WP
HttpModules
Caching
HttpHandlers
Pages Services
ASP.NET Modular ArchitectureASP.NET Modular Architecture
ASPNET_ISAPI
Authent Sessions SessionState
ASPNET_STATE
INETINFO
ASPNET_WP
HttpModules
Caching
HttpHandlers
Pages Services
ASP.NET Error RecoveryASP.NET Error Recovery
ASPNET_ISAPI
Authent Sessions SessionState
Crash!Hang!
ASPNET_STATE
INETINFO
ASPNET_WP
HttpModules
Caching
HttpHandlers
Pages Services
ASP.NET Error RecoveryASP.NET Error Recovery
ASPNET_ISAPI
Authent Sessions SessionState
State Server State Server 사용하기사용하기
ConfigurationConfiguration
Page Page 들이 담겨있는 디렉토리와 동일한 곳에 들이 담겨있는 디렉토리와 동일한 곳에 XML XML 형태의 파일을 위치한다형태의 파일을 위치한다 web.configweb.config
모든 모든 ASP.NET ASP.NET 설정 값들을 저장하고 있음설정 값들을 저장하고 있음 Authentication, compile options, Authentication, compile options,
custom error pages, etc.custom error pages, etc. 사용자 정의 설정값을 추가할 수 있다사용자 정의 설정값을 추가할 수 있다
DSN, etc.DSN, etc. 확장확장
Custom Custom 한 설정 값들을 얼마든지 지정가능한 설정 값들을 얼마든지 지정가능
IBuySpy Configuration IBuySpy Configuration 의 예의 예<configuration>
<appSettings> <add key="DSN" value="server=(local);uid=sa;pwd=;database=ibs2" /> </appSettings>
<location path="CheckOut.aspx"> <system.web> <authorization> <deny users="?" /> </authorization> </system.web> </location>
<system.web>
<authentication mode="Forms"> <forms name="IBuySpyAuth" loginUrl="Login.aspx" protection="all"> </authentication>
<customErrors mode="RemoteOnly" defaultRedirect="ErrorPage.aspx"/>
</system.web></configuration>
<appSettings> <add key="DSN" value="server=(local);uid=sa;pwd=;database=ibs2" /> </appSettings>
<location path="CheckOut.aspx"> <system.web> <authorization> <deny users="?" /> </authorization> </system.web> </location>
<authentication mode="Forms"> <forms name="IBuySpyAuth" loginUrl="Login.aspx“ protection="all“> </authentication>
<customErrors mode="RemoteOnly" defaultRedirect="ErrorPage.aspx"/>
Dim strConn as String = _ Dim strConn as String = _ ConfigurationSettings.AppSettings(“DSN”)ConfigurationSettings.AppSettings(“DSN”)
Machine.config & Machine.config & Web.configWeb.config
ASP.NET AuthenticationASP.NET Authentication
IIS IIS 에서 지원하는 에서 지원하는 Basic, Digest and NTLMBasic, Digest and NTLM Credential verification against NT SAM/DSCredential verification against NT SAM/DS
Passport modulePassport module Exposes passport profile APIExposes passport profile API
Custom, forms-based authenticationCustom, forms-based authentication Cookie token tracking Cookie token tracking 을 이용한 손쉬운 사용을 이용한 손쉬운 사용 Custom login screen (no popup dialogs)Custom login screen (no popup dialogs) Credential checks against database, etc.Credential checks against database, etc.
ASP.NET DeploymentASP.NET Deployment
““XCOPY” deploymentXCOPY” deployment 설치등록 이 필요없다설치등록 이 필요없다 !!!! 웹 서버를 더 이상 세울 일이 없다웹 서버를 더 이상 세울 일이 없다 !!
모든 웹 모든 웹 Resource Resource 들을 마찬가지로 들을 마찬가지로 Just Just Copy!Copy! Web pages, web servicesWeb pages, web services Compiled components (DLL)Compiled components (DLL) Configuration filesConfiguration files
Component DeploymentComponent Deployment
Component Component 설치 누워서 떡먹기설치 누워서 떡먹기 !! FtpFtp 로 로 Application Application 의 의 //bin bin 폴더로 폴더로 Just xcopy ! Just xcopy ! 설치 등록 과정 필요없음설치 등록 과정 필요없음
((Bye Bye Registry! Bye Bye Regsvr32!! )Bye Bye Registry! Bye Bye Regsvr32!! ) ““\bin” \bin” 폴더는 각각의 폴더는 각각의 Application Application 에 에 Private Private 하다하다
각각의 각각의 Application Application 들은 각자의 들은 각자의 Component Component 를 를 호출해야 한다호출해야 한다 ..
실시간 실시간 Component UpdateComponent Update No more locked DLLsNo more locked DLLs Just copy new DLL on top of old one!Just copy new DLL on top of old one!
간단한 간단한 uninstall — just delete files!uninstall — just delete files! Registry Registry 와는 전혀 상관없음와는 전혀 상관없음
ASP.NET ASP.NET Web ServicesWeb Services 55
ASP.NET Web ServiceASP.NET Web Service
SOAPSOAP XMLXML Distributed Internet ApplicationDistributed Internet Application Beyond the COM+Beyond the COM+
Yellow pagesYellow pages http://uddi.microsoft.com http://www.uddi.org
Building Web ApplicationsBuilding Web Applications
PartnerPartnerPartnerPartner
Credit Info
Credit Info
SocketSocket
ScreeScreennScrapScrapee
FAXFAX EmailEmail
ClientClient
B2CWebsite
B2CWebsite
HTMLHTML
ClientClient
Using Web ServicesUsing Web Services
B2CWebsite
B2CWebsite
PartnerPartnerPartnerPartner
Credit Info
Credit Info
XMLXML
XMLXML
XMLXML XMLXML
이득 : 정보 제공자 / 소비자 자동화 ,정확한 데이터에 의한 정보 공유및 분석이 가능
ClientClient
XMLXML
B2CWebsite
B2CWebsite
PartnerPartnerPartnerPartner
Credit Info
Credit Info
Simple, Open, Broad Support
전송수단 : Internet
Service 의 게시 , 검색 , 사용 : UDDI
상호 서비스 연동 : SOAP
범용 데이터 전송매개 : XML
XMLXML
Web Services in ASP.NETWeb Services in ASP.NET
단순한 프로그래밍 모델단순한 프로그래밍 모델 단순히 단순히 ASMX ASMX 파일에 클래스 메소드를 작성파일에 클래스 메소드를 작성 ASP.NET ASP.NET 이 해당 서비스 이 해당 서비스 Request Request 시 시 Compile, Compile,
클래스 내부의 각각의 클래스 내부의 각각의 Method Method 들에 대한 정보를 들에 대한 정보를 HTML HTML 형식으로 생성시킴형식으로 생성시킴
HTTP HTTP 상으로 들어오는 상으로 들어오는 Request Request 들이 들이 Method Method 들을 호출한다들을 호출한다 .. 별도로 별도로 HTTP HTTP 나 나 XML XML 제반 지식을 필요로 하지 않음제반 지식을 필요로 하지 않음
다양한 다양한 Message Wire Format Message Wire Format 을 지원을 지원 HTTP Get, Post, SOAP RequestHTTP Get, Post, SOAP Request
Basic NamespaceBasic Namespace ImportsImports System.Web.ServicesSystem.Web.Services 반드시 참조 되어야 한다반드시 참조 되어야 한다 !!
WebMethod WebMethod 키워드와 함께 키워드와 함께 Class Class 정의정의
본 메소드는 웹 에서 호출가능 하다본 메소드는 웹 에서 호출가능 하다 !! Public Public 만으로는 웹에서 만으로는 웹에서 Access Access 할 수 없다할 수 없다 !!
웹 서비스 작성방법웹 서비스 작성방법
Public Class MyStore<WebMethod()> _ Public Function Price() As String
Price = "The item costs $10." End FunctionEnd Class
Public Class MyStore<WebMethod()> _ Public Function Price() As String
Price = "The item costs $10." End FunctionEnd Class
웹 서비스 실행 모델웹 서비스 실행 모델
Web ServicesWeb Services 로로Hello World Hello World 만들기만들기
SummarySummary
Windows DNAWindows DNA 에서 에서 ..NETNET 으로으로 .NET Framework.NET Framework 의 이해의 이해 ASPASP 에서 에서 ASP.NETASP.NET 으로으로 단순함과 강력함단순함과 강력함 빠른 속도와 확장성빠른 속도와 확장성 안정성과 가용성안정성과 가용성 ASP.NET Platform – Pages, Services, ASP.NET Platform – Pages, Services,
InfrastructureInfrastructure
More Resources..More Resources.. http://www.asp.nethttp://www.asp.net http://www.http://www.gotdotnetgotdotnet.com.com http://www.http://www.asptodayasptoday.com.com http://www.http://www.ibuyspyibuyspy.com.com http://www.http://www.fmstockfmstock.com.com http://http://localhostlocalhost//quickstartquickstart (ASP.NET quickstart) (ASP.NET quickstart) MSDNMSDN 그외 관련 서적들그외 관련 서적들 ....
Contact to ..Contact to ..noenemy@[email protected]
http://www.noenemy.nethttp://www.noenemy.net