Tampilkan postingan dengan label ASP. Tampilkan semua postingan
Tampilkan postingan dengan label ASP. Tampilkan semua postingan

Jumat, 02 Desember 2011

Mengenal ASP

ASP adalah singkatan dari Active Server Pages yang merupakan salah satu bahasa pemograman web
untuk menciptakan halaman web yang dinamis. ASP merupakan salah satu produk tekhnologi yang
disediakan oleh Microsoft. ASP diproses melalui web server dan hasil proses ini menghasilkan HTML
yang akan dikirimkan melalui browser.

ASP bekerja pada web server dan merupakan server side scripting. Berbeda dengan VBScript yang

bekerja pada client atau disebut juga client side scripting. Meskipun demikian ASP mengunakan
VBScript sebagai bahasa dasar untuk pemogramannya.

Karena bersifat server side scripting maka ASP dapat bekerja pada semua web browser berbeda dengan

client side scripting yang bekerja hanya tergantung pada browser. Sebagai contoh VBScript hanya bisa
dijalankan pada browser Internet Explorer dan tidak dapat dijalankan pada browser Netscape.

ASP sangat mudah dipelajari. Yang diperlukan hanyalah mengenal HTML dan VBScript. Dengan ASP

anda bisa membangun aplikasi web yang dinamis. ASP juga dikenal sangat populer bersaing dengan
PHP serta yang web language yang lainnya seperti Java Servlet, Cold Fusion, dll.

ASP diperkenalkan ke dunia pertama kali oleh Microsoft pada tanggal 16 Juli 1996, dan diberi nama

kode Denali. Beta version dirilis pada bulan November 1996, dan akhirnya ASP Version 1.0 secara
resmi dipasarkan ke publik pada tanggal 12 Desember 1996.

Microsoft terus mengembangkan ASP. Pada tahun 1998, Microsoft telah mengeluarkan software web

server yang terbaru,  Internet Information Server 4.0 (IIS 4.0) yang berjalan pada Windows NT 4.0
dan Personal Web Server 4.0 (PWS 4.0) yang berjalan pada Windows ‘98. Software web server yang
baru ini dapat support ASP Version 2.0.

Dengan dirilisnya Windows 2000, maka Microsoft meluncurkan Internet Information Server 5.0 (IIS

5.0) dan versi terbaru ASP Version 3.0.  IIS 5.0 sebenarnya lebih terintegrasi dengan Windows 2000
dalam satu paket sistem operasi.

ASP semakin dikenal luas tepatnya sejak maret 1997. ASP semakin populer karena mudah untuk

dipelajari. Tentunya masih banyak web programming language yang lainnya seperti PHP, Cold Fusion,
Java Servlet, dll yang tidak kalah populernya ASP.

Itulah sekilas tentang sejarah ASP dan pengenalannya. Marilah kita lanjutkan pada tahap berikutnya. 


2. Web Dinamis


Di atas kita mungkin sudah dijelaskan sekilas mengenai ASP yang diciptakan untuk membuat halaman

web menjadi dinamis. Mungkin ada beberapa dari kita bertanya-tanya apa sih web yang dinamis ? 

Secara gamblang web yang dinamis dan statis bisa dibedakan pada tampilannya. Jika kita melihat suatu

isi halaman web yang hanya berhubungan dengan halaman web yang lain maka kita bisa menyebut web
tersebut sifatnya statis. Kenapa statis ? Karena user hanya bisa melihat isi dokumen pada halaman web
dan jika diklik maka dokumen akan berpindah ke halaman web selanjutnya. Interaksi user dengan
browser hanya sebatas melihat informasi tetapi tidak bisa mengolah informasi yang dihasilkan.

Web statis biasanya hanya merupakan HTML yang diketik melalui teks editor yang disimpan dalam

bentuk .html atau .htm. Sedangkan web yang dinamis memungkinkan kita untuk berinteraksi dengan
menggunakan form sehingga kita bisa mengolah informasi yang ditampilkan.


3. Apa Yang Diperlukan Untuk Menjalankan ASP ?


Sekilas kita sudah dijelaskan mengenai ASP, server side scripting, client side scripting dan web dinamis

secara singkat. Mungkin kita sudah tidak sabar lagi untuk mencoba belajar ASP, tetapi sebelumnya kita
harus mengetahui bagaimana dan apa yang diperlukan untuk menjalankan ASP.
 •  Untuk memulai menulis bahasa pemograman ASP diperlukan minimal sebuah text editor atau
bisa juga web development tools yang lain seperti Visual Interdev, Homesite, Dreamweaver, dll.
•  Web server yang support ASP. Tutorial ini menggunakan Internet Information Server (IIS
5.0) yang mensupport ASP Version 3.0, IIS 5.0 tersedia pada sistem operasi Windows 2000.
Jadi maka sebaiknya gunakan IIS 5.0 sebagai web server ASP pada tutorial ini. Sebenarnya
ASP juga bisa berjalan pada web server lain seperti Apache, Lotus, dll yang berjalan pada
sistem operasi non windows seperti Unix/Linux, dll. Contohnya adalah Chili!Soft ASP yang bisa di download di http://www.chilisoft.com dengan masa trial 30 hari.
•  Untuk melihat dan melakukan test pada suatu halaman, kita tentunya memerlukan web browser.
Seperti yang sudah dijelaskan di atas bahwa ASP bisa berjalan pada semua browser. Dalam
tutorial ini penulis menggunakan Internet Explorer 6.0 SP1.
•  Yang terakhir dan tidak kalah penting adalah anda harus mengetahui tag-tag HTML supaya bisa
mengikuti pelajaran ini dengan baik. 


4. Instalasi Internet Information Service 5.0


Jika semuanya sudah disiapkan maka langkah selanjutnya adalah instalasi IIS 5.0. Bagi anda

menggunakan yang windows 95/98/NT anda bisa baca dokumentasinya akan tetapi sebaiknya dalam
tutorial ini anda menggunakan IIS 5.0 yang sudah tersedia dalam windows 2000 atau sistem operasi
windows yang terbaru semenjak tulisan ini dibuat yaitu Windows XP Professional. Bagi anda yang
menggunakan windows 2000 anda bisa lakukan langkah berikut untuk :

1.  Buka control panel (Start – Settings – Control Panel) dan pilih icon Add/Remove Programs.

2.  Pilih Add/Remove Windows Components yang terletak pada sebelah kiri.
3.  Pilih Internet Information Services (IIS). Jika sudah dicheckbox maka IIS sudah terinstall
Jika belum maka check Internet Information Services (IIS) option kemudian klik details
4.  Pilih semuanya untuk mendapatkan semua fungsi dan feature dari IIS. Pastikan option
FrontPage 2000 Server Extensions dicek jika ingin menggunakan Front Page 2000 atau
Visual InterDev sebagai web editor untuk ASP. Klik OK maka dialog box akan berpindah
ke sebelumnya. Geser scroll bar ke bawah, cek Script Debugger option. Script debugger
memungkinkan kita untuk melakukan debug pada script ASP kita.
5.  Kemudian klik next maka sistem akan menginstruksikan kepada kita untuk memasukkan
Windows 2000 Installation CD ke dalam CDROM. Setup akan memakan waktu beberapa
menit untuk menyelesaikannya.

6.  Setelah instalasi selesai maka buka windows explorer, maka folder C:\Inetpub sudah terbuat.

Berikut fungsi singkat masing-masing folder :
•  \iisamples\homepage berisi ASP sample pages.
•  \iisamples\sdk  berisi subdirektori yang menyimpan ASP script yang
mendemonstrasikan beberapa ASP object dan komponen.
•  \scripts isinya direktori kosong yang berguna untuk menyimpan script yang sudah
dibuat.
•  \webpub isinya juga direktori kosong yang digunakan untuk feature Publish Wizard.
Hanya ada jika anda menggunakan Windows 2000 Professional Edition.
•  \wwwroot  direktori ini merupakan top folder untuk website anda. Ini menjadi
default web directory. Anda bisa membuat sub direktori di sini untuk membangun
website anda.
•  \ftproot, \mailroot  dan  \nntproot merupakan direktori yang berisi ftp, mail dan
news service.
7.  Anda bisa mentest apakah web server sudah terinstalasi dengan baik atau tidak. Oleh karena itu cobalah buka Internet Explorer. Ketik pada kolom address. http://localhost atau http://namakomputer


5. Virtual Directories


5.1 Mengenal virtual directories


Pada bagian di atas kita sudah belajar cara menginstalasi web server. Jika masih belum berhasil dalam

menginstalasi IIS 5.0, anda bisa menghubungi penulis untuk penyelesaian lebih lanjut. Sekarang mari
kita belajar bagaimana caranya untuk membuat virtual directories serta mengaturnya.

Virtual directories berguna untuk menampung file-file ASP/HTML kita yang akan dipublish ke dalam

suatu direktori web server. Berbeda dengan file-file .html atau .htm yang disimpan dalam suatu direktori
biasa seperti C:\My documents\mywebpage.html, tempat penyimpanan seperti ini disebut juga Physical
Directories.

Browser memang bisa menampilkan web page yang ada di physical directories akan tetapi halaman web

yang ditampilkan sebenarnya bukan melalui protokol HTTP seperti yang dipakai dalam standard internet
yang seharusnya. Pertimbangan lainnya adalah alamat yang akan digunakan untuk menampilkan
halaman web pada physical direktories sebab biasanya browser akan menampilkan web page pada web
server address berupa http:// sedangkan alamat pada physical directories adalah file://.

Oleh karena itu maka diperlukanlah virtual directories dalam web server yang berguna untuk

menampung file-file web page yang nantinya bisa digunakan browser untuk menampilkan web page
melalui protokol http yang sebenarnya.

Virtual directories ini bisa disimpan pada folder C:\inetpub\wwwroot. Jika misalnya kita membuat folder

C:\inetpub\wwwroot\test\ dan menempatkan file default.asp di folder test, maka syntax pengetikan pada browser adalah http://namakomputer/test/default.asp.


5.2 Membuat virtual directories

Pada dasarnya membuat virtual directories sangat mudah. Anda bisa mencoba membuatnya dan ikuti

langkah-langkah di bawah ini. Direktori ini akan digunakan terus selama kita berlatih ASP :

1.  Buka windows explorer dan buat sebuah physical directory dan beri nama “LatihanASP” pada

folder C:\inetpub\wwwroot.
2.  Selanjutnya kita buka IIS admin tools. Berikut cara membukanya : Start – Settings – Control
Panel – Administrative Tools – Internet Services Manager.
3.  Arahkan kursor mouse pada Default Web Site kemudian klik kanan New – Virtual Directory.
Maka akan muncul dialog screen berjudul New Virtual Directory Creation Wizard, kemudian
klik Next.
4.  Pada layar berikutnya ketik “LatihanASP” pada kotak alias dan kemudian klik Next untuk
melanjutkan.
5.  Click Browse… button dan pilih direktori C:\inetpub\wwwroot\LatihanASP yang sudah dibuat
pada point 1. Kemudian klik Next.
6.  Pastikan bahwa Read dan Run Scripts di cek supaya web page dapat ditampilkan. Kemudian
klik Next dan klik Finish.

7.  Selesailah sudah kita membuat virtual directory dengan nama LatihanASP. Anda bisa

melakukan setting pada virtual directory yang sudah anda buat. Untuk melihat fungsi-fungsinya
secara singkat, anda bisa melangkah ke sub bab selanjutnya.


5.3 Setting Virtual Directories


Pada sub bab sebelumnya, kita sudah membuat sebuah virtual directory LatihanASP. Sekarang tinggal

bagaimana caranya kita melakukan setting virtual directory yang sudah kita buat.

Pada IIS admin tools, silahkan anda right click pada LatihanASP virtual directory dan pilih properties.

Memang terlalu banyak option yang bisa kita lakukan, akan tetapi kita belajar option penting yang sering
digunakan.

1.  Application.

Pada contoh di atas application sudah dibuat. Jika masih kosong maka Create button akan
muncul, sebaliknya Remove button akan muncul. Application nantinya berguna bagi global.asa
yang akan dibahas pada bab selanjutnya.

2.  Access permission.

•  Script source access.
Jika dicek maka memungkinkan user mengakses source code script ASP kita. Script
source access membutuhkan option Read dan Write dicek.
•  Read.
Jika option Read tidak dicek maka browser tidak akan bisa menampilkan web page
yang akan ditampilkan. Secara default option Read dicek.
•  Write.
Jika option Write dicek maka memungkinkan user untuk membuat atau memodifikasi
file yang ada di dalam direktori.
•  Directory browsing.
Option ini memungkinkan semua isi file atau folder dari sebuah virtual directory
ditampilkan di layar browser.

3.  Execution Permissions.

•  None.
Memungkinkan user hanya dapat mengakses file-file static seperti html files dan
gambar. Semua file yang berisi script tidak dapat diakses oleh user.
•  Scripts Only.
Memungkinkan user untuk mejalankan script yang ada di direktori ini seperti ASP files
dan mengembalikan dalam bentuk HTML ke browser. Secara default option ini dicek
dan direkomendasikan supaya option scripts only saja yang dipilih.
•  Scripts and Executeables.
Sebaiknya option ini jangan digunakan jika tidak benar-benar penting karena melalui
option ini user dimungkinkan untuk melakukan eksekusi file-file di dalam direktori ini.


6. Coba File ASP Anda

  
Pada beberapa sub bab sebelumnya kita telah sedikit mengenal sejarah ASP, melakukan instalasi IIS 5.0,
membuat virtual direktories. Nah sekarang tinggal selangkah lagi kita akan memasuki pelajaran inti
yaitu belajar membuat script ASP. 

Web server sudah terinstall, virtual direktori sudah dibuat, kita juga sudah lihat hasil test browser yang

menunjukkan web server kita dapat bekerja dengan baik. Sekarang mungkin anda penasaran bagaimana
sih caranya mendemonstrasi file ASP yang sudah kita buat ?

Oleh karena itu mari ikuti langkah-langkah berikut untuk membuat syntax ASP yang sangat sederhana :

1.  Buka file text editor apa saja seperti notepad. Atau bisa juga menggunakan web development
tools seperti homesite, visual interdev, dll. Terserah anda lebih senang menggunakan tools yang
mana.
2.  Kemudian ketik saja code seperti di bawah ini :

<html>

<head>
<title>Testing Page</title>
</head>
<body>
 <h1>Selamat Datang</h1>
  Halo nama saya <% response.write "Johanes Gunawan" %><br>
  Dan sekarang jam web server menunjukkan <%= Time %>
</body>
</html>

3.  Mungkin selama mengetik, anda bertanya-tanya kira-kira apa kegunaan syntax response.write

dan time ? Serta apa artinya <% dan %> ? Hal ini akan dibahas pada bab selanjutnya, sekarang
silahkan simpan filenya ke dalam virtual directory (C:\inetpub\wwwroot\LatihanASP) dan beri
nama test.asp.
4.   Silahkan buka browser anda, kemudian anda ketik pada kolom address http://namakomputer/latihanASP/test.asp.
5.  Silahkan mencoba tekan refresh maka jam akan berubah sesuai dengan jam yang ada di sistem.
6.  Untuk melihat hasil parsing asp yang berupa html dari web server, anda bisa pilih menu View –
Source Code, maka akan terlihat source code seperti gambar di bawah ini. Yang perlu anda
perhatikan adalah bahwa script ASP yang telah anda buat, tidak terlihat pada gambar di bawah,
hal itu karena ASP script diproses hanya di web server dan hasilnya akan dikembalikan dalam
bentuk tag-tag HTML yang kemudian ditampilkan oleh browser.

Minggu, 27 November 2011

ASP.net Vs ASP

This article explains the difference between the Classic ASP and ASP.Net and also focuses on the new features in ASP.NET. Let's discuss the differences between these two in detail:
Process Isolation
ASP is running under the inetinfo.exe (IIS) process space and hence susceptible to application crashes due to that the IIS needs to be stopped or restarted. ASP is related to the process isolation setting in IIS. Where as, ASP.Net process is separate from inetinfo.exe (IIS process). Though the entry point into a ASP.Net application is still IIS but it is not related to the IIS process isolation settings.
Non-MS Platform Support
Classical ASP has no mechanism of running itself on non- Microsoft technology platforms like the "The Apache Web Server" (there are some third party products, like ChiliSoft) but, ASP.NET could be run on non- Microsoft Platforms also. Cassini is a sample Web server produced by Microsoft which, among other projects, has been used to host ASP.NET with Apache.
Multi Language Support in WebPage
Only VBScript and Javascript were available for scripting in ASP where as, in ASP.NET there are no such restrictions. The .NET compliant language can be used with ASP.NET including several like C# and VB.NET, where both of them are server-sided languages.
Interpretation Vs Compilation
In ASP, an interpreter like Jscript or VBScript is used to execute the server-side code. When an ASP page is requested, the text of that page is parsed linearly. The content that is not server-side script is passed back as it is to the response. Where as, the server-side script in the page is executed through the appropriate interpreter, and the output is then submitted back to the response. The efficiency of page rendering is affected by this architecture in several ways. Firstly, on the go interpreting of the server-side script. A common optimization for the ASP applications for this side affect is to move a mass of server-side script into precompiled COM components to improve the response time. Secondly, the intermingling server-side evaluation blocks with static HTML is another efficiency concern. It is less efficient than the evaluating a single server-side blocks because the interpreter has to be invoked time and again.
As a rescue, many ASP developers resort to large blocks of server-side script for replacing static HTML elements with Response.Write() invocations instead. Eventually, this ASP model permits the inclusion of different blocks of scripts within a page to be written in different script languages. This may appeal in some ways but it also reduces performance by requiring that a particular page load both scripting engines to process a request that consumes more time and memory if compared to just using one language.
But in ASP.NET, the pages are always compiled into .Net classes housed within assemblies. This class includes both the server-side code and static HTML, so when the page is accessed for the first time, subsequent rendering of that page is serviced by executing the compiled code. All the inefficiencies of the scripting model of traditional ASP are eliminated by this. No longer had any performance difference between compiled components and server-side code embedded within a page observed. Both of them are compiled assemblies now. Also, no performance difference between interspersing server-side code blocks among static HTML elements and writing large blocks of server side code and using Response.Write() for static HTML content. The .aspx file is parsed into a single code file and compiled, its not possible to use multiple
This eliminates all the inefficiencies of the scripting model of traditional ASP. There is no longer any performance difference between compiled components and server-side code embedded within a page they are now both compiled components. There is also no performance difference between interspersing server-side code blocks among static HTML elements, and writing large blocks of server-side code and using Response.Write() for static HTML content. Also, because the .aspx file is parsed into a single code file and compiled, it is not possible to use multiple server-side languages within a single .aspx file.
Debugging benefits
In classic ASP, debugging is a tough task because of limited support due to the interpreted model. In contrast, not only ASP.NET improves the performance over the interpreted model but also provides debugging tools for component developers and pages compiled into classes. The page errors are generated as compiled errors and there is a fir chance that most of them will be discovered at the compilation time instead of runtime due to the fact that VB.Net and C# are strongly typed languages. In addition to this, the tools available to the Windows Forms .Net developer are applicable to the ASP.NET developer.
Server-Side code placement Web Page
In ASP pages you might include the executable code outside the scope of a function within a script block marked as "runat=server" and you may also define a function within a pair of server side script tags. Where as in ASP.Net the former is no longer supported and the latter is also not possible.
A default constructor is provided by the generated class definition, and it would be a compiler error if you try to write a default constructor. For this, you can choose the alternative method of separating the layout from the page logic which consequently gives you a complete control over the class definition. This method is called code-behind.
Deployment Strategies
The components used by pages and deployed in this manner were difficult to update or replace in the Classic ASP. You are required to shutdown the IIS because of the fact that while the application was functioning, it referred to the component file for replacement. So, after taking your web server temporarily offline, you had to replace the file and then restart IIS. But, in ASP.NET it aimed to get rid of the need to stop the functioning Web application whenever the components needed to be updated or replaced.
To attain this, the designers of ASP.NET had to ensure two things: first, that the running application not hold a reference to the component file and second, that whenever the component file was replaced with a new version, that new version was picked up with any subsequent requests made to the application. Both of these goals are achieved by using the shadow copy mechanism provided by the Common Language Runtime (CLR).
New Page Directives
In ASP, the directives are required to be placed on the first line of a page within the same delimiting block. For instance:
<%LANGUAGE="VBSCRIPT" CODEPAGE="932"%>
While ASP.NET required you to place the Language directive with a Page directive, as follows:
<%@Page Language="VB" CodePage="932"%> <%@QutputCache Duration="60" VaryByParam="none" %>
It could be more than one directive lines, which depends on your need. The standard practice is to place the directives in the beginning of the file but you can place it anywhere in your .aspx file.
Threading Issues
The threading model of COM object created using VB within a web-based application is STA (Single Threaded Apartment). ASP worker thread resides in its own STA and hence the compatibility is fine in this case with a little performance hit.
But in ASP.NET, threading model is the Multiple Threaded Apartment (MTA). This means that components that you are using were created for the Single Threaded Apartment (STA) will no longer perform or function reliably without taking some extra precautions in ASP.NET. This includes, but is not limited to, all COM components that have been created using Visual Basic 6.0 and earlier versions. You will be glad to hear that you can still use these STA components without having to change any code. What you need to do is include the compatibility attribute aspcompat=true in a <%@Page> tag on the ASP.NET page. For example, <%@Page aspcompat=true Language=VB%>. Using this attribute will force your page to execute in STA mode, thus ensuring your component will continue to function correctly. If you attempt to use an STA component without specifying this tag, the run time will throw an exception. Setting this attribute to true will also allow your page to call COM+ 1.0 components that require access to the unmanaged ASP built-in objects. These are accessible via the ObjectContext object. If you set this tag to true, your performance will degrade slightly.
Validation & Browser scripting capabilities
  • There is no inbuilt facility for the validation of controls in the Classic ASP. For example, checking whether a textbox is left blank, or a combo is selected or not, or if a phone number does not fit a particular pattern for area etc.
  • These kinds of validations required the user to write the client side Javascript code.
  • It was not less than a headache for the developer to cater the client and server side validations.
  • What added to the burden on the developer was the Javascript code to fit a particular Browser. Specific code had to be written to fit a set of browsers and it consumed a lot of time.
But in ASP.NET, In built validation controls are provided which are easy to implement and the developer has to worry the least.
The features provided by ASP.NET validation controls:
  • Browser Independent coding: Developer does not have to worry about the browser and how controls would render to.
  • Client-Side or Server-Side: The Validation Controls manage the code checking if the client side code is disabled the validation is done on the server side.
Rich Validation set
There are few types of validation which cater to the needs of the validation requirements:
  • RequiredFieldValidation Control - Requires that the control not be left blank.
  • CompareValidator Control - Used to compare Data in Two Controls
  • RangeValidator Control - Used to check for Range validation (also supports various data Types - Date, string etc...)
  • RegularExpressionValidator Control - Used to check the complicated patterns in the user input.
  • CustomValidator Control - The final control we have included in ASP.NET is one that adds great flexibility to our validation abilities. We have a custom validator where we get to write out own functions and pass the control value to this function.
This control also provides Client side and server side validation of which the Server side validation could be a different function altogether.
Validation Summary
The validation summary control will collect all the error messages of all the non-valid controls and put them in a tidy list. The list can be either shown on the web page (as shown in the example above) or with a popup box.
Conclusion
Classic ASP goes a long way toward simplifying Web programming. It is demanding when it comes to writing a new DDL from the very beginning as compared with the easier task to write some HTML and mingle it with a script. But then Classic ASP is not fee of issues. The ASP pages are mass of unstructured code. It can be compared to the early days of BASIC programming, where achieving a task quickly was possible but the resultant code was often hard to follow. The object model of ASP has multiple inherent or global objects. For instance, for the generation of the content of an HTTP request, script code is written and the content is send to the client using the intrinsic Response object. In the guaranteed situations where only one client is involved in talking to your Web application, this isn't much of a problem. But not many web applications guarantee this. And the reason for this is the way ASP is organized by these intrinsic objects.
ASP.Net improves the classic ASP. The same intrinsic objects still remain in ASP.Net and the scripting can be added anywhere on the page per you requirement. In fact, ASP.NET easily manages and runs most of the ASP pages with .aspx extension.
ASP.Net introduces a lot of new features. Like all the components within .Net, ASP.Net pages too are compiled into the assemblies, which give a performance and security edge. Further, it supports the usage of any .Net language. This means there is no restriction over the use of JavaScript or VB Script on your Web pages. Now, you have an option to use more structured languages.
ASP.Net opens up a whole new programming model with the blend and combination of Web forms, server-side controls, data binding, and Web services.