BUG: You may receive an HTTP 405 "Method not allowed" error message when you browse the default document without specifying the file name (216493)



The information in this article applies to:

  • Microsoft Internet Information Services 5.0
  • Microsoft Internet Information Server 4.0

This article was previously published under Q216493

SYMPTOMS

When you browse the default document, you receive one of the following error messages:
HTTP Error
405 Method Not Allowed

The method specified in the Request Line is not allowed for the resource identified by the request. Please ensure that you have the proper MIME type set up for the resource you are requesting.

Please contact the server's administrator if this problem persists.
HTTP 405 - Resource not allowed
Internet Information Services
This problem occurs if the following conditions are true:
  • You do not specify the file name. For example, you do not specify http://Server/Web/.
  • The Scripting Object Model (SOM) is enabled.
  • A DTC event is called.

CAUSE

This problem occurs only when you use Microsoft Internet Information Services (IIS) 4.0 and Microsoft Internet Information Services 5.0. This problem occurs if you send a POST request to a server that is running IIS 4.0 or IIS 5.0, and the POST request contains a URL that ends in a slash mark (/). IIS returns the 405 error message instead of the default document. However, if the method value of the Verb property is GET or HEAD, IIS returns the default document.

RESOLUTION

When the SOM is enabled and a DTC event is called

When the SOM is enabled for the page, a <FORM> tag that is similar to the following is inserted in the page.
<FORM name=thisForm METHOD=post>
				
Because no ACTION attribute is specified in the tag, both Netscape Navigator and Internet Explorer try to make an HTTP POST request to the URI "web/". According to the HTTP RFC (RFC 2068), this is not a valid Request-URI for a POST operation.

To work around this problem, use one of the following methods:
  • Redirect from the default document to a different document. In this case, the SOM-enabled document will no longer be the default document. The new default document will just redirect to the SOM-enabled document. For example, if your SOM-enabled document is named MyDefault.asp, the default document (Default.asp) will contain only the following code.
      <%
      Response.Redirect "mydefault.asp"
      %>
    						
  • Use client-side script to make sure that the file name is included in the URL. If you must use your SOM-enabled document as the default document, use a client-side code block that is similar to the following code block as the first code block within the <HEAD> section of the page. This code block does the following location replacement.
    <SCRIPT Language=JavaScript>
      var loc = document.location.toString()
      var loclen = loc.length
      
      //The name of the default document
      var filename = "default.asp"     
      var filelen = filename.length
      
      loc = loc.substring(loclen - filelen, loclen)
      
      if (loc.toUpperCase() != filename.toUpperCase()) { 
        location.replace(filename) 
      }
    </SCRIPT>
    						

When the remote scripting is called

This problem may occur if you use the window.location.href property in an HTML document to determine the path of the current document. If you do this when you initiate a remote scripting call, the remote scripting call fails because the client page does not have a file name.

To determine whether the page can use remote scripting on the client, verify that the value of the window.location.href property does not end in a slash mark. To provide a file name in the client browser, and to prevent the error on the server, use the Response.Redirect method redirect the request from the default page to another page. For more information, see the first resolution method in the "When the SOM is enabled and a DTC event is called" section.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

This bug was corrected in Microsoft Internet Information Services 6.0.

Modification Type:MajorLast Reviewed:12/8/2004
Keywords:kbBug kbCtrl KB216493 kbAudDeveloper kbAudITPRO