Showing posts with label IIS. Show all posts
Showing posts with label IIS. Show all posts

Wednesday, February 13, 2013

View Detailed Information on 500 - internal server error

 
You'll get the error "500 - internal server error" due to some invalid setting in your application. With out having more detailed information error we can not say what causes the error to occur.

To View a detailed error message add the below settings in you'r web.config.
<system.web>
<customErrors mode="Off"></customErrors>
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed" />
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</system.webServer>

Tuesday, January 15, 2013

How to Create Virtual Directory in IIS

 
When you’re ready to deploy a website on a computer that has IIS, the first step you’ll usually take is to create the physical directory where the pages will be stored (for example, c:\MySite). The second step is to expose this physical directory as a virtual directory through IIS. This means the website becomes publicly visible to other computers that are connected to your computer. Ordinarily, a remote computer won’t be allowed to access your c:\MySite directory. However, if you map c:\MySite to a virtual directory, the remote user will be able to request the files in the directory through IIS.

Before going any further, choose the directory you want to expose as a virtual directory. You can use any directory you want, on any drive, and you can place it as many levels deep as makes sense. You can use a directory that already has your website files, or you can copy these files after you create the virtual directory. Either way, the first step is to register this directory with IIS.

The easiest and most flexible way to create a virtual directory is to use the IIS Manager utility. Here’s what you need to do:

1. To create a new virtual directory for an existing physical directory, expand the node for the current computer, expand the Web Sites node underneath, and then right-click the Default Web Site item.

2. If you’re using IIS 5 or IIS 6, choose New -> Virtual Directory from the context menu. A wizard will start to manage the process (see Figure - 1). As you step through the wizard, you’ll be asked to supply the information IIS needs. If you’re using IIS 7, choose Add Application directory. You’ll be asked to supply essentially the same information, but in a single window (see Figure - 2).

Figure - 1


Figure - 2


3. The first piece of information you need to supply is the alias—the name a remote client will use to access the files in this virtual directory. For example, if your alias is MyApp and your computer is MyServer, you can request pages using URLs such as http://MyServer/MyApp/MyPage.aspx.

4. Choose a directory. The directory is the physical directory on your hard drive that will be exposed as a virtual directory. For example, c:\Inetpub\wwwroot is the physical directory that is used for the root virtual directory of your web server. IIS will provide access to all the allowed file types in this directory.

5. If you’re using IIS 5 or IIS 6, there’s one more step. You need to choose the permissions for your virtual directory. To host an ASP.NET application, you need only to enable the read and execute permissions (the first two check boxes). If you’re using a development computer that will never act as a live web server, you can allow additional permissions. (Keep in mind, however, that this could allow other users on a local network to access and modify files in the virtual directory.)

6. If you’re using IIS 7, you can also specify the application pool by clicking the Select button. An application pool is a group of settings that applies to one or more applications. 

7. To finish the process in IIS 5 or IIS 6, advance to the end of the wizard and then click Next. In IIS 7, you simply need to click OK in the Add Virtual Directory dialog box. 

When you finish these steps, you’ll see your new virtual directory appear in the list in IIS Manager. You can remove an existing virtual directory by selecting it and pressing the Delete key, or you can change its settings by right-clicking it and choosing Properties (in IIS 5 and IIS 6) or selecting it and using the icons in the Features View on the right (in IIS 7).

Once you’ve created your virtual directory, fire up a browser to make sure it works. For example, if you’ve created the virtual directory with the alias MyApplication and it contains the page MyPage.aspx, you should be able to request http://localhost/MyApplication/MyPage.aspx. 

Wednesday, January 9, 2013

Adding Your Site to IIS 7

 
In my previous post i have shown you how to install IIS 7 on windows server. In this post you'll see how to add your site to IIS 7.

1. Open IIS manager -> Right click on Site -> Add Web Site



2. Enter the Site name, Select physical path of the application and enter the host name. Binding section details might be changed according to your network configurations.



3. Click on application pools. Then you'll see a new application pool is created with you'r site name.




4. If your application is in .NET framework 4.0 do the following.
Double click on the application pool name of your site and change the framework to 4.0

Wednesday, January 2, 2013

Retrieving the COM class factory for component with CLSID {8CFEBA94-3FC2-45CA-B9A5-9EDACF704F66} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

 
Recently i received the above error when i tried to host my application on IIS 7.0. I solved my issue by doing the following.

  1. Create a dedicated application pool for the site in IIS.
  2. Go to application pool advance settings
  3. Set application pool identity to "Network Services"

Below is the complete error description i received.

Retrieving the COM class factory for component with CLSID {8CFEBA94-3FC2-45CA-B9A5-9EDACF704F66} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {8CFEBA94-3FC2-45CA-B9A5-9EDACF704F66} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

Sunday, December 23, 2012

How to Install IIS on Windows 7

 
1. Select Control Panel from your start menu.



2. Select Programs and Features.




3. Select Windows Features on or off from the left side pane.



4. Expand the Internet Information Service Node and Select the features.


Tuesday, December 11, 2012

Get Client IP Address

 
The ServerVariables collection is used to retrieve the server variable values. There are collection of available server variables which helps to retrieve client information. We can use "REMOTE_ADDR" server variable to get the IP address of the client who is browsing the website.

private void GetUserIP() //This method will print the Client IP address
{
  string UIP= Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ??     Request.ServerVariables["REMOTE_ADDR"];
  Response.Write(UIP.ToString());
}

"HTTP_X_FORWARDED_FOR" is the real IP address if a proxy is being used.

Available server variables are listed below.

Variable
Description
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_PASSWORD
Returns the value entered in the client's authentication dialog
AUTH_TYPE
The authentication method that the server uses to validate users
AUTH_USER
Returns the raw authenticated user name
CERT_COOKIE
Returns 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_ISSUER
Returns the issuer field of the client certificate
CERT_KEYSIZE
Returns the number of bits in Secure Sockets Layer connection key size
CERT_SECRETKEYSIZE
Returns the number of bits in server certificate private key
CERT_SERIALNUMBER
Returns the serial number field of the client certificate
CERT_SERVER_ISSUER
Returns the issuer field of the server certificate
CERT_SERVER_SUBJECT
Returns the subject field of the server certificate
CERT_SUBJECT
Returns the subject field of the client certificate
CONTENT_LENGTH
Returns the length of the content as sent by the client
CONTENT_TYPE
Returns the data type of the content
GATEWAY_INTERFACE
Returns 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_USER
Returns the Windows account that the user is logged into
PATH_INFO
Returns 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_STRING
Returns 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