Affichage des articles dont le libellé est ASP. Afficher tous les articles

Download : ASP.NET Questionnaire / PDF

Download : ASP.NET Questionnaire / PDF











Download : ASP.NET Questionnaire / PDF












Question: Why a conventional ASP web page is considered to be stateless amd how do u overcome this using ASP.NET?

Answer: Whenver a URL request is made, Web server creates instance of requested web form, generates HTML and posts it to browser for rendering. It then destroys instance of web form on the server. When user submits data back to the web server, a new instance of web form is created which has no knowledge of earlier webform. Hence conventional web page is stateless. In ASP.NET before web form get destroyed the state of the webform is stored in Viewstate(hidden control) on the page and when the page is posted back, the state of the webform is restored from view state.


Question: What is a web-farm and how do u manage session in web-farm?

Answer: A web-farm is group of webservers hosting a single web application. Sice the web application is shared across multiple servers, session info can not be stored in process memory of any of servers. It should be stored in a centralizes database or state machine.


Question: What is difference between following statements
                           1 - <%@ outputcache duration=”60” varybyparam=”none”>
                           2 - <%@ outputcache duration=”60” varybyparam=”*”>
                           3 - <%@ outputcache duration=”60” varybyparam=”name”>

Answer: Statement 1 caches only one version of the page irrespective of querystring
parameters. Statement 2 caches multiple versions of same page I any of
quewrystring parameter varies. Statement 3 caches multiple versions of the
page for different values of parameter xyz.



Question: What are 2 expiration policies for Cached objects?
Answer:

1. Absolute expiration: This is fixed duration expiration. For cache duration of 10 seconds, object is removed from cache after 10 seconds no matter what.

2. Sliding expiration: Canche duration varies based on frequency of access. E.g. If there is sliding expiration of 10 seconds and item is accessed from the cached again at 8th second, then object is reached again for the next 10 seconds.......














Download : ASP.NET Questionnaire / PDF




0

Exercises :Active Server Pages (ASP)

Exercises :Active Server Pages  (ASP)


Exercises :Active Server Pages  (ASP)
























Active Server Pages has the capability of working with the information stored in databases.  The connection of web servers (web servers need to be running ASP technology) to databases is through ActiveX Data Objects (ADO) technology.  Basically ADO is a library of objects that enable applications to communicate with 'data sources' (does not have to be a database necessarily.  It could be the file system of your computer.  Microsoft's vision of 'universal data'). In this tutorial we will use;

1.    The connection object to connect to the data source for reading data.
2.    The recordset object to represent the particular data we will read.
3.    The command object to allow invoking operations (for example deleting data) on the data source.

The main task is to configure the properties of each object.  Then one of the methods of the object is used to carry out the particular task at hand (for example reading/writing data to/from datasource).

Exercise 1    Read appointments from the database 'database.mdb'.

You are provided with;
·         A space on a server that the server administrator has named 'pertinax'.  The URL for the server is 'http://pertinax.cms.shu.ac.uk/' and the URL for your space on that server is  'http://pertinax.cms.shu.ac.uk/general/your directory'.
A username allows access to your particular space.
·         A password.
·         A Data Source Name (DSN).
·         A database (Access database) that server administrator has named 'database.mdb'.

Note that server administrator has tied your DSN to a database named 'database.mdb' in your space.  This means one DSN for one database.

You have to use the recordset object for storing the data that comes from the database that has been defined in the connection object. There are five steps to extract data and present it.

Tasks;
A.   Create recordset object using createobject().
B.   Create the SQL statement for the retrieval of data.
C.   Define a connection object for the recordset object to use as active connection.
D.   Use the recordset's open method, passing the SQL statement to populate the recorset with data from the source.
E.   Create HTML that formats the display of data.

1.         Now let us construct the HTML page.
For this purpose this has to be a simple page.  It has to have a form that would include a button.  If button is clicked we would connect to the ASP file called say 'car_booking.asp'.  The bit of code that does this is

action="http://hadrian.cms.shu.ac.uk/general3/your directory/car_booking.asp">

Save the file in your home-space and name it 'car_booking.html'.

2.         Now let us construct the ASP page.  (Do not include the text inside the curly brackets)

<%@ Language=VBScript %>

{Task A}
<%set objdbconnection = server.createobject("ADODB.Connection")

{Task C&D}       
objdbconnection.open "Your DSN"

{Task B}
     SQLquery = "select fname,lname,carname,apptime,appday from clients,cars,appointments where clients.clientid=appointments.clientid and cars.carid=appointments.carid"
set rslist = objdbconnection.execute(sqlquery)
%>
FirstNameLastNameCarTimeDay

{Task E}
<%while not rslist.eof%>
<%=rslist("fname")%>
<%=rslist("lname")%>
<%=rslist("carname")%>
<%=rslist("apptime")%>
<%=rslist("appday")%>
<%rslist.movenext
wend%>

3.  Download the database "database.mdb"
4.  FTP the two files and the database to the server.
5.  Use your browser window to navigate to your server space.  You should see the three items.
6. Open the HTML file and click on the button.  You should see the appointments in your browser window.

Exercise 2

For this exercise you could try to write to the database.  A little bit more complicated.  We now need three files and the database on the server.

1.         You could alter the 'car_booking.html' to include another form that would provide a second button say 'Add a New Car to Database'.  This form would connect to a ASP file called say 'add_car.asp'.  This bit of code could be

action="http://pertinax.cms.shu.ac.uk/general/your directory/add_car.asp">



2.         'add_car.asp file would read one complete record for table  'cars' in the database.  You would need a form here that would provide a button say 'Add Car to Database' that when clicked would connect to a third file named say 'car_added.asp'.  The bit of the code that does this could be

            Action="http://hadrian.cms.shu.ac.uk/general3/your directory/car_added.asp">

Car ID
Car Name
Car Size (Choose a number from 1 to 4)
>



3.         The third file, in this case called 'car_added.asp' inserts the record into the database.  Just one line of code is required....






Download Exercises :Active Server Pages  (ASP)












Exercises :Active Server Pages  (ASP)
0

Learn about ASP

Learn about ASP




Learn about ASP



















ASP Tutorial






















 
In our ASP tutorial you will learn about ASP, and how to execute scripts on your server.
You will see that ASP is a powerful tool for making dynamic and interactive Web pages.

Active Server Pages. A specification that enables Web pages to be dynamically created using HTML, scripts, and reusable ActiveX server components.

A dynamically generated web page, generally using ActiveX scripting. When a browser or a search engine spider requests an ASP page from a server, the server generates the web page with HTML code and gives it to the browser or spider.

The abbreviation ASP has several meanings: * Active Server Pages - which is a web server extension by Microsoft.* Advanced Simple Profile - a profile used in digital video codecs, such as XviD and Nero Digital* amnesic shellfish poison - a marine biotoxin and neurotoxin (aka domoic acid).* Application service provider - a business that serves clients with computer application needs (compare to internet service provider or ISP)

Active Server Pages. The default scripting language used for writing ASP is VBScript, although you can use other scripting languages like JScript. Also see PSP, JSP and JSP. Application Service Provider. A provider of applications through the internet.

ASP is Microsoft's server-side scripting technology. An Active Server Page has an .asp extension and it mixes HTML and scripting code that can be written in VBScript or JScript. ASP is distributed with Microsoft's IIS web server, so most host using IIS will also offer ASP for dynamic web programming. ASP.NET is the next version of ASP. Other popular server-side scripting languages are Perl, PHP, ColdFusion, TCL, Python, and JSP.









Lesson 1: Introduction to ASP 

An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are executed on the server

What you should already know

Before you continue you should have some basic understanding of the following:
  • HTML / XHTML
  • A scripting language like JavaScript or VBScript
If you want to study these subjects first, find the tutorials on our Home page.

What is ASP?

  • ASP stands for Active Server Pages
  • ASP is a program that runs inside IIS
  • IIS stands for Internet Information Services
  • IIS comes as a free component with Windows 2000
  • IIS is also a part of the Windows NT 4.0 Option Pack
  • The Option Pack can be downloaded from Microsoft
  • PWS is a smaller - but fully functional - version of IIS
  • PWS can be found on your Windows 95/98 CD

ASP Compatibility

  • ASP is a Microsoft Technology
  • To run IIS you must have Windows NT 4.0 or later
  • To run PWS you must have Windows 95 or later
  • ChiliASP is a technology that runs ASP without Windows OS
  • InstantASP is another technology that runs ASP without Windows

What is an ASP File?

  • An ASP file is just the same as an HTML file
  • An ASP file can contain text, HTML, XML, and scripts
  • Scripts in an ASP file are executed on the server
  • An ASP file has the file extension ".asp"

How Does ASP Differ from HTML?

  • When a browser requests an HTML file, the server returns the file
  • When a browser requests an ASP file, IIS passes the request to the ASP engine. The ASP engine reads the ASP file, line by line, and executes the scripts in the file. Finally, the ASP file is returned to the browser as plain HTML

What can ASP do for you?

  • Dynamically edit, change or add any content of a Web page
  • Respond to user queries or data submitted from HTML forms
  • Access any data or databases and return the results to a browser
  • Customize a Web page to make it more useful for individual users
  • The advantages of using ASP instead of CGI and Perl, are those of simplicity and speed
  • Provides security since your ASP code can not be viewed from the browser
  • Since ASP files are returned as plain HTML, they can be viewed in any browser
  • Clever ASP programming can minimize the network traffic





Lesson 2: Run ASP on Your PC 

You can run ASP on your own PC without an external server. To do that, you must install Microsoft's Personal Web Server (PWS) or Internet Information Services (IIS) on your PC.

How to Run ASP on your own PC

You can run ASP on your own PC without an external server. To do that, you must install Microsoft's Personal Web Server (PWS) or Internet Information Services (IIS) on your PC.
If you are serious about using ASP, you should have at least Windows 98, Second Edition. 
If you are really serious about using ASP, you should go for Windows 2000.

How to install PWS and run ASP on Windows 95

Personal Web Server (PWS) is not shipped with Windows 95 !!
To run ASP on Windows 95, you will have to download "Windows NT 4.0 Option Pack" from Microsoft.

How to install PWS and run ASP on Windows NT

Personal Web Server (PWS) is not shipped with Windows NT !!
To run ASP on Windows NT, you will have to download "Windows NT 4.0 Option Pack" from Microsoft.

How to install PWS and run ASP on Windows 98

  1. Open the Add-ons folder on your Windows98 CD, find the PWS folder and run the setup.exe file.
  2. An Inetpub folder will be created on your harddrive. Open it and find the wwwroot folder.
  3. Create a new folder, like "MyWeb", under wwwroot.
  4. Use a text editor to write some ASP code, save the file as "test1.asp" in the "MyWeb" folder.
  5. Make sure your Web server is running - The installation program has added a new icon on your task bar (this is the PWS symbol). Click on the icon and press the Start button in the window that appears.
  6. Open your browser and type in "http://localhost/MyWeb/test1.asp", to view your first ASP page.

How to install PWS and run ASP on Windows ME

Personal Web Server (PWS) is not included with Windows Me !!
Read article from Microsoft
A workaround!

How to install IIS and run ASP on Windows 2000

  1. From your Start Button, go to Settings, and Control Panel
  2. In the Control Panel window select Add/Remove Programs
  3. In the Add/Remove window select Add/Remove Windows Components
  4. In the Wizard window check Internet Information Services, click OK
  5. An Inetpub folder will be created on your harddrive
  6. Open the Inetpub folder, and find a folder named wwwroot
  7. Create a new folder, like "MyWeb", under wwwroot.
  8. Use a text editor to write some ASP code, save the file as "test1.asp" in the "MyWeb" folder
  9. Make sure your Web server is running - The installation program has added a new icon on your task bar (this is the IIS symbol). Click on the icon and press the Start button in the window that appears.
  10. Open your browser and type in "http://localhost/MyWeb/test1.asp", to view your first ASP page

How to install IIS and run ASP on Windows XP Professional

Note: You cannot run ASP on Windows XP Home Edition.
  1. Insert the Windows XP Professional CD-Rom into your CD-Rom Drive
  2. From your Start Button, go to Settings, and Control Panel
  3. In the Control Panel window select Add/Remove Programs
  4. In the Add/Remove window select Add/Remove Windows Components
  5. In the Wizard window check Internet Information Services, click OK
  6. An Inetpub folder will be created on your harddrive
  7. Open the Inetpub folder, and find a folder named wwwroot
  8. Create a new folder, like "MyWeb", under wwwroot.
  9. Use a text editor to write some ASP code, save the file as "test1.asp" in the "MyWeb" folder
  10. Make sure your Web server is running - its status can be checked by going into the Control Panel, then Administrative Tools, and double-click the "IIS Manager" icon
  11. Open your browser and type in "http://localhost/MyWeb/test1.asp", to view your first ASP page

How to install IIS and run ASP on Windows Server 2003 (Windows .NET Server)

  1. When you start the Windows Server 2003, you should see the Manage Your Server wizard
  2. If the wizard is not displayed, go to Administrative Tools, and select Manage Your Server
  3. In the wizard, click Add or Remove a Role, click Next
  4. Select Custom Configuration, click Next
  5. Select Application Server role, click Next
  6. Select Enable ASP.NET, click Next
  7. Now, the wizard may ask for the Server 2003 CD. Insert the CD and let it run until it is finished, then click the Finish button
  8. The wizard should now show the Application Server role installed
  9. Click on Manage This Application Server to bring up the Application Server Management Console (MMC)
  10. Expand the Internet Information Services (IIS) Manager, then expand your server, and then the Web Sites folder
  11. You should see the Default Web Site, and it should not say (Stopped)
  12. IIS is running!
  13. In the Internet Information Services (IIS) Manager click on the Web Service Extensions folder
  14. Here you will see that Active Server Pages are Prohibited (this is the default configuration of IIS 6)
  15. Highlight Active Server Pages and click the Allow button
  16. ASP is now active!





Lesson 3: ASP Syntax 

You cannot view the ASP source code by selecting "View source" in a browser, you will only see the output from the ASP file, which is plain HTML. This is because the scripts are executed on the server before the result is sent back to the browser.
In our ASP tutorial, every example displays the hidden ASP source code. This will make it easier for you to understand how it works.

Examples

Write text with ASP
How to write some text with ASP.

Add some HTML to the text
How to format the text with HTML tags.


The Basic Syntax Rule

An ASP file normally contains HTML tags, just like an HTML file. However, an ASP file can also contain server scripts, surrounded by the delimiters <% and %>. Server scripts are executed on the server, and can contain any expressions, statements, procedures, or operators valid for the scripting language you prefer to use......




Download Learn about ASP











Learn about ASP

0

Download Tips to Becoming a Better ASP Coder / PDF

Download Tips to Becoming a Better ASP Coder / PDF










Download Tips to Becoming a Better ASP Coder / PDF
























What Exactly Are Active Server Pages?

Active Server Pages, commonly referred to as ASP, is Microsoft's solution to server-side scripting. With simple HTML pages, the client (a web surfer) requests a web page from a server (some www.blah.com). The server just sends the file to the client, and the page is shown on the client's browser.

With Active Server Pages, the server gets a chance to alter the file before sending it to the user. So, for every request for a file with a .ASP extension, the server runs the file through a DLL called ASP.DLL, which parses the ASP commands.

To use Active Server Pages you must be running a Microsoft webserver; Microsoft makes a number of Web servers that are freely available. If you have Windows NT 4.0 Server installed, you can download IIS 3.0 or IIS 4.0, both of which support ASP development. If you have Windows 2000, you can use IIS 5.0. If you have Windows 9X or Windows NT Workstation, you can use Personal Web Server (PWS).

 All of these products can be downloaded for free from Microsoft's Web site: http://www.microsoft.com/iis/
If your web site is run on a UNIX box, you can still use Active Server Pages, but you need to use a third party tool to translate the ASP before it is sent to the client. Such companies like Chilisoft make products of this nature.

If you are running a Microsoft Web server, to run an ASP file, all you need to do is create a file on the webserver with a .ASP extension. When the browser requests the file, the webserver is smart enough to preprocess the file before sending it off to the client.

You can have your ASP code connect to a database (SQL, Access, Oracle, Informix, or any ODBC-compliant database) and dynamically insert the data into your HTML pages. This leads to some very powerful possibilities including ECommerce, customizable sites, data entering / retrieving systems run over the Internet, and a slew of other possibilities. You can view some web sites that use ASP by visiting most any Microsoft sponsored site such as MSNBC.com or The Zone.


Why ASP?

Before you decide to use ASP to implement your web application, you should do some serious thinking to determine if ASP is the correct solution for your particular problem.
If you need a dynamic web site, with database connectivity, and you already are using IIS 3.0 or up, then ASP is obviously the simple choice. If you are using a UNIX server and want to use ASP, you have two options:
  • Buy a third part product, like Chilisoft, to run your ASP on a non-Microsoft web server, or
  • Move your site to a host who provides NT webservers.

There are many advantages to using ASP. They include database connectivity, the ability to create dynamic web sites, and the ease with which you can create web sites to sell inventory on the web. ASP is nice because it is free! ASP's biggest advantage, in my opinion, is that it is easy to learn, especially for those who are familiar with VisualBASIC.

There are also non-Microsoft development tools for sale to create dynamic web sites, but those products (such as Cold Fusion) aren't free. ASP, however, is!

It is easier, in my opinion, to write dynamic sites using ASP than it is using Perl on a UNIX box. UNIX webservers are more stable than NT servers, though, and Perl script will most often run quicker than ASP script.
In summation, if you have a Microsoft webserver, the choice is pretty obvious if you want a dynamic website.

ASP Basics: What's Happening Back There?

With each new language it seems computers get easier and easier to program. When computers first came into existence, programmers needed to know very cryptic and specific machine instructions to make those ancient behemoths do anything. Before too long assembly languages arose, and then high-level programming languages were introduced with the creation of Fortran. Today we have reusable components, GUI/WYSIWYG designers, and easy to use scripting languages.

As computers become easier and easier to program, though, developers have to know less of what's happening in the bowels of the compiler or interpreter. While this saves time, I think it is important to have a firm grasp on what's going on behind the scenes. I think this is an important thing to know for two reasons: one, it's cool; two, having a better understanding of what's really happening leads to better written code, fewer bugs, and an improved self-esteem!

Before we begin discussing how ASP pages "work," let's talk about how static HTML pages "work." The Internet is built on a client/server foundation. That means that there are two parts we must look at when dissecting an Internet transaction: the client and the server. The client is the web browser, be it Internet Explorer, Netscape, Lynx, Opera, or whatever. The server is the web server on which the HTML page exists.

The entire process of retrieving a web page goes like this:
  • You type in the URL into your browser, for example http://www.yahoo.com/index.html
  • Your browser finds the appropriate web server, and to that server says, "I need to look at the file /index.html, please."
  • The web server locates the file /index.html and sends it to the browser as HTML text.
  • The browser collects this text and parses it, determining how to display those colorful animated gifs and blinking text we've all come to love.
It's that simple. The transaction has just three simple steps: the client requests the document, the web server sends the document, the client decides how to display it. With ASP, however, there are some additional steps are taken on the server before the HTML text is sent back to the client. Let's look at what happens with ASP:
  • You type in the URL into your browser, for example http://www.ASPisNeat.com/default.asp
  • Your browser finds the appropriate web server, and to that server says, "I need to look at the file /default.asp, please."
  • The web server locates the file /default.asp and parses out the ASP code, turning all of the ASP code into applicable HTML code. ASP code is code inbetween the ASP script delimiters (<% ... %>) or in OBJECT tags with the RUNAT=Server property set. Since all of the ASP is parsed into HTML, the client sees absolutely no ASP code!
  • The browser collects this HTML text and parses it, determining how to display those colorful animated gifs and blinking text we've all come to love.
You'll note that there is again just three steps, although the second step is a bit more involved. The whole process starts with the client requesting a file with a .ASP extension. The web server notes the extension, and since it has a .ASP extension (as opposed to a .txt, .htm or .html), the server parses the contents of the requested file before sending it to the client. So when you view an ASP file through IE or Netscape, your browser doesn't know that the .asp file is any different from a standard .html file!

One of the things that makes ASP a bit tricky for beginners is the fact that there is two kinds of scripting: client-side scripting, and server side scripting. Client-side scripting is HTML code that the browser interprets. For example, you can have a message box appear when a page is loaded by adding:
 
at the bottom of your HTML page. This is client-side scripting. The web server makes no note of client-side code, it just sends it to the client like regular HTML text. It is the client's responsibility to process client-side scripts.
Server-side scripts, like ASP, are scripts that the web server processes. Since server-side scripts are processed by the web server, the client (or browser) does not interact with the server-side scripts. Since all ASP code is processed before the client obtains any client-side script, it is impossible for ASP to make use of client-side actions without requiring a round trip to the server.
You can insert server-side variables into client-side script. Since the server-side script will be processed before the client receives the HTML content, and since client-side scripts are synonymous with HTML content, you can write server-side script variables to the client-side scripts rather simply.
<%
               Dim strMessage
               strMessage = "Hello, world!"
%>
 
What you cannot do is have server-side script make use of client-side variables, methods, or events. Since the server-side script has completely been processed by the time any client-side code is processed, client-side code cannot impact the server-side code in any way. If you want to take a server-side action based on a client-side event, you must make a round-trip to the server.
Finally, in case you were wondering, the reason you get an error if you try:
<%
               MsgBox ("Hello World!")
%>
is because the function MsgBox is a client-side function (it displays a message box on the client's screen). Since it is strictly a client-side function, it is not available for server-side scripting. Hence the error.
I hope this article has helped you better understand the difference between the client and server when it comes to the Internet, and, hopefully, you've gained a better understanding of how ASP pages are processed.



Getting Started with ASP
By Akshay Luther

Welcome to the wonderful and exciting world of ASP. This article is focussed on passing on knowledge and information that I have had to acquire the hard way in a nice compact high-powered package. For more beginner-level ASP information, also be sure to check out the Beginner ASP FAQs on 4Guys.
Skip the next few paragraphs if you already know what ASP and are familiar with the client/server model for web applications.
Well, what is it? ASP is a server-side Microsoft technology that provides an environment for Server Side programming. It lets you use either Jscript (Microsoft's version of JavaScript) or more commonly VBScript to write scripts that execute on the server. So why is it so cool? Primarily, because it lets you create HTML on-the-fly. It lets you do this based on, for starters, two very ..........




















Download Tips to Becoming a Better ASP Coder / PDF
0

Tags