Saturday, September 29, 2007

Where are IIS log files stored?

To determine where your IIS log files are stored, please execute the steps below on your server:
1. Go to Start -> Control Panel -> Administrative Tools
2. Run Internet Information Services (IIS)
3. Find your web site under the tree on the left and right-click on it.
4. Choose properties
5. On the Web Site tab, you should see an option near the bottom that says "Active Log Format." Next to it is a Properties button. Click on the Properties button.
6. At the bottom of the General Properties tab, you'll see a box that contains the log file directory and the log file name. The full log path is comprised of the log file directory plus the first part of the log file name.

How to execute DOS commands in ASP.

To execute DOS commands ,we use Wscript.shell Object.

Befor doing it we need to check whether Windows Script Host is installed and also check whether it is enabled. If every thing is proper then we can say the object is ready for use ...
------------------------------------------------
<%
set Wshell = Server. CreateObject ( "WScript.Shell")
Wshell.run "c:\mytests\test1.exe"
set wshell = nothing
%> set wshell = CreateObject("WScript.Shell")
wshell.run "c:\testfile.exe"
set wshell = nothing
------------------------------------------------------
Be sure you need to use the local path of the file to be executed and also check for the permissions.



To retrieve the Output from Command

Lets take an example of Ping Command from an IP adress..

-------------------code------------

Response.Buffer = true
Set objWShell = CreateObject("WScript.Shell")
Set objCmd = objWShell.Exec("ping " & url)
strPResult = objCmd.StdOut.Readall()
Set objCmd = nothing:
Set objWShell = nothing
strStatus = "offline"
if InStr(strPResult,"TTL=")>0 then
strStatus = "online"
response.write url & " is " & strStatus
response.write ".
" & replace(strPResult,vbCrLf,"
")
-------------------------



*************************************************************************







Server.Transfer , Server.Execute , Response.Redirect Methods

Server.Transfer Vs Server.Execute

Server.Transfer Methods sends all the state information from one page to another.
When the second Page completes its task it doesn’t come back to the first page.

Server.Execute Method sends all the state information from one page to other ,similar to Server.Transfer .Here when the second page completes its task,It returns to the first page.

Server.Execute executes the page and return the results..


Server.Transfer is almost similar to the Response.Redirect but there exists some difference.

Lets look on it.

Server.Transfer Vs Response.Redirect.



Well, Response.Redirect and Server.Transfer are used to transfer user form one page to another. So,whats the difference between them..

Response.Redirect simply sends a message down to the browser, telling it to move to another page. Response.Redirect ("WebForm2.aspx”)

Server.Transfer is similar in that it sends the user to another page with a statement such as

Server.Transfer ("WebForm2.aspx")


Server.Transfer method conserves server Resources. It will change the focus on the server and sends the other requests instead of saying it to redirect .SO,we will get less HTTP requests compare to Response.Redirect which therefore reduces the pressure on the web server.

Server.Transfer can only works on the applications that resides on the server. It cannot transfer to external sites as Response.Redirect does.

Server.Transfer has a parameter called PreserveForm. When it is set to true,it preserves the form variables and query strings and will be available to other page you transferred to.

Server.Transfer ("WebForm2.aspx",true)

So all the variables in webform1 are available to webform2.

Monday, September 24, 2007

**************Marriage Thoughts**********************

Thought 1 When we are born, our mothers get the compliments and the flowers. When we are married, our brides get the presents and the publicity. When we die, our widows get the life insurance. What do women want to be liberated from? ---------------------------------------------------------------------------- ----------------------
Thought 2 The average man's life consists of : Twenty years of having his mother ask him where he is going, Forty years of having his wife ask the same question; and at the end, the mourners wondering too. ---------------------------------------------------------------------------- ----------------------
Thought 3
A man was walking down a street when he heard a voice from behind, "If you take one more step, a brick will fall down on your head and kill you." The man stopped and a big brick fell right in front of him. The man was astonished. He went on, and after a while he was going to cross the road. Once again the voice shouted, "Stop! Stand still! If you take one more step a car will run over you, and you will die." The man did as he was instructed, just as a car came careening around the corner, barely missing him. The man asked. "Who are you?" "I am your guardian angel," the voice answered. "Oh, yeah?" the man asked "And where the hell were you when I got married?" ---------------------------------------------------------------------------- ----------------------
Thought 4

Everyone in the wedding ceremony was watching the radiant bride as her father escorted her down the aisle to give away to the groom. They reached the altar and the waiting groom; the bride kissed her father and placed some thing in his hand. Everyone in the room was wondering what was given to the father by the bride. The father could feel the suspense in the air and all eyes were on him to divulge the secret and say something. So he announced "Ladies and Gentlemen today is the luckiest day of my life." Then he raised his hands with what his daughter gave him and continued, "My daughter finally, finally returned my credit card to me." The whole audience including priest started laughing.......... but not the poor groom.

Sunday, September 23, 2007

Server Variables Collections

Server Variables Collections:

Syntax: Request.ServerVQriqbles("Server_Variables")

Request.ServerVariables (server_variable)

Parameter Description
server_variable Required. The name of the server variable to retrieve

Server Variables

VariableDescription
ALL_HTTP Returns all HTTP headers sent by the client. Always prefixed with HTTP_ and capitalized
ALL_RAW Returns all headers in raw form
APPL_MD_PATH Returns the meta base path for the application for the ISAPI DLL
APPL_PHYSICAL_PATH Returns the physical path corresponding to the meta base path
AUTH_PASSWORDReturns the value entered in the client's authentication dialog
AUTH_TYPE The authentication method that the server uses to validate users
AUTH_USERReturns the raw authenticated user name
CERT_COOKIEReturns the unique ID for client certificate as a string
CERT_FLAGS bit0 is set to 1 if the client certificate is present and bit1 is set to 1 if the cCertification authority of the client certificate is not valid
CERT_ISSUERReturns the issuer field of the client certificate
CERT_KEYSIZEReturns the number of bits in Secure Sockets Layer connection key size
CERT_SECRETKEYSIZEReturns the number of bits in server certificate private key
CERT_SERIALNUMBERReturns the serial number field of the client certificate
CERT_SERVER_ISSUERReturns the issuer field of the server certificate
CERT_SERVER_SUBJECTReturns the subject field of the server certificate
CERT_SUBJECTReturns the subject field of the client certificate
CONTENT_LENGTHReturns the length of the content as sent by the client
CONTENT_TYPEReturns the data type of the content
GATEWAY_INTERFACEReturns the revision of the CGI specification used by the server
HTTP_<HeaderName>Returns the value stored in the header HeaderName
HTTP_ACCEPT Returns the value of the Accept header
HTTP_ACCEPT_LANGUAGE Returns a string describing the language to use for displaying content
HTTP_COOKIE Returns the cookie string included with the request
HTTP_REFERER Returns a string containing the URL of the page that referred the request to the current page using an <a> tag. If the page is redirected, HTTP_REFERER is empty
HTTP_USER_AGENT Returns a string describing the browser that sent the request
HTTPS Returns ON if the request came in through secure channel or OFF if the request came in through a non-secure channel
HTTPS_KEYSIZE Returns the number of bits in Secure Sockets Layer connection key size
HTTPS_SECRETKEYSIZE Returns the number of bits in server certificate private key
HTTPS_SERVER_ISSUER Returns the issuer field of the server certificate
HTTPS_SERVER_SUBJECT Returns the subject field of the server certificate
INSTANCE_ID The ID for the IIS instance in text format
INSTANCE_META_PATH The meta base path for the instance of IIS that responds to the request
LOCAL_ADDR Returns the server address on which the request came in
LOGON_USERReturns the Windows account that the user is logged into
PATH_INFOReturns extra path information as given by the client
PATH_TRANSLATED A translated version of PATH_INFO that takes the path and performs any necessary virtual-to-physical mapping
QUERY_STRINGReturns the query information stored in the string following the question mark (?) in the HTTP request
REMOTE_ADDR Returns the IP address of the remote host making the request
REMOTE_HOST Returns the name of the host making the request
REMOTE_USER Returns an unmapped user-name string sent in by the user
REQUEST_METHOD Returns the method used to make the request
SCRIPT_NAME Returns a virtual path to the script being executed
SERVER_NAME Returns the server's host name, DNS alias, or IP address as it would appear in self-referencing URLs
SERVER_PORT Returns the port number to which the request was sent
SERVER_PORT_SECURE Returns a string that contains 0 or 1. If the request is being handled on the secure port, it will be 1. Otherwise, it will be 0
SERVER_PROTOCOL Returns the name and revision of the request information protocol
SERVER_SOFTWARE Returns the name and version of the server software that answers the request and runs the gateway
URL Returns the base portion of the URL

Wednesday, September 19, 2007

Session Management in ASP

ASP Sessions



The Session object stores information needed for a particular user's session on the web server. It is automatically created every time when an ASP page from the web site or web application is requested by a user who does not already have a session, and it remains available until the session expires.

The Session object is user specific. It can be used to store variables specific to a particular user and IIS will maintain these variables when the client moves across pages within your web site.
ASP Sessions are cookie based, it uses HTTP Cookies to send users their unique session keys. Asp application responds to the users request with an http header that consists of a unique session key(for the first time) and subsequent requests from the same browser are identified by the session key.


ASP automatically processes this cookie and uses it to restore the values saved in the Session object. The cookie that is sent by ASP as a session ID does not provide an expiration time. Cookies with no expiration specified are only valid until the browser is closed. In this way the cookie is flushed when the user exits the browser.

The Session object is based on using cookies, so if cookies are not permitted on the client browser, the Session object is rendered useless and the page stop working.

How Asp Session Works

When a user sends a web page request, In response to the request, the server creates a cookie that consists the session id for the particular user and Place it in the HTTP Header and sends it before it sends any HTML output. Even the ASP script doesn’t need any session management it sends unique session id for every request to the server from the user until a session state is created. If the session state is not created for the particular session id for the next request from the browser it will send another session id. Once the script stores some value in the session , for the next requests from the browser it uses the session id to identify the user.

We can turn off the sessions in our applications if we don’t need it by using the registry.
The AllowSessionState registry or configuration file setting controls the creation of Session objects. If AllowSessionState is set to False, the Session object cannot be used. The default is to use Sessions


ASP Session objects consists
Collections
Methods
Properties


Syntax: Session. Collections Property Method
1. Collections: Asp Session Objects Collection are


Contents: contains Items that have been created for Session. Contents can be used to get a value of item, to iterate through all the items, to remove items. Remove method of the collection helps to remove the item from the collection. To remove all the items we use Removeall method

Session.Contents.Count gives number of items in the collection

To remove item from the sessions collection .let us suppose “Age” in our example
Session.Contents.Remove(“age”)
To remove all session items .
Session.Contents.Removeall()

Static Objects : contains items created in global.asa file with .the collection can be used to get value of an specific item Session.StaticObjects(key) Key is the item to retrieve


2. Properties
Code Page
LCID
SessionID
Timeout

CodePage : The Codepage property defines the code page that will be used to display the page content in the browser. A code page is a character set containing all the alphanumeric characters and punctuation used by a specific locale
Session.CodePage sets the code page for an entire session. Code pages tell the server how to encode characters for different languagesSession.CodePage [= CodePageID]

Codepage is an integer that represents character formatting code page.
Session.CodePage affects the entire session where as Response.codepage affects the current page.

If codepage is set then charset should also be set
Codeset indicates how to encode
Charset indicates how to decode when displaying responses
The Charset property appends the name of the character set) to the Content-Type header in the Response object.


LCID : The LCID property is used to set or get the locale identifier (LCID) of the page is sent to the browser. The local identifier is used to control how dates, times and currencies will be displayed according to the specific location or region.

SessionId : The SessionID is a read-only property that uniquely identifies each current user's session. Each session has a unique identifier that is generated by the server when the session is created and stored as a cookie on the client machine.

Timeout : The Timeout property sets or returns the timeout period (in minutes) for thе Session object in this application. If the user does not refresh or request a page within the timeout period, the session ends. Can be changed in individual pages as required. The default timeout period is 20 mts.Timeout property can be changed using following syntax

Session. Timeout = (no of minutes)


3. Methods
Abandon: To end a session immediately or to destroy the session objects,we use the Abandon method in the script
Remove:to remove any particular item from session collection we use remove method
Remove All:to remove all the items from sessions contents collection we go for session.removeall()