Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an ASP.NET site that uses its own set of HTTP handlers and does not need any modules.

So, in IIS6, all I had to do was this in my web.config:

<httpModules>
    <clear />
</httpModules>

However, if I try to do the same in the system.webServer area for IIS7, I get a 500 error when I try to view the site, and in IIS manager when I try to view the handler mappings, I get a popup box with the message:

There was an error while performing this operation

Details:

Filename:

\?\C:\Sites\TheWebSiteGoesHere\web.config

Line number: 39

Error: Lock violation

Line 39 is where the <clear /> element is.

Some googling led me to a solution involving running this command:

%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/modules

...but that did not solve the problem.

share|improve this question

3 Answers 3

up vote 8 down vote accepted

That's by design. The section of system.webServer essentially defines IIS itself. If you , you won't be left with anything. In applicationHost.config, you should have something like this:

        <modules>
            <add name="HttpCacheModule" lockItem="true" />
            <add name="DynamicCompressionModule" lockItem="true" />
            <add name="StaticCompressionModule" lockItem="true" />
            <add name="DefaultDocumentModule" lockItem="true" />
            <add name="DirectoryListingModule" lockItem="true" />
            <add name="IsapiFilterModule" lockItem="true" />
            <add name="ProtocolSupportModule" lockItem="true" />
            <add name="HttpRedirectionModule" lockItem="true" />
            <add name="StaticFileModule" lockItem="true" />
            ...

Notice the lockItem properties. Because there are 1 or more lock items, will throw a lock violation.

So, you either need to specifically remove just the items that you don't want from web.config, or if you really need to clear them all and add back your own, then in applicationHost.config remove the lockItem="true" on each of those elements, and make sure to add enough of them back so that your web server will actually work.

Edit

(Appended further information from Daniel, per his request. (Scott))

Here is what I did based on what Scott said:

Opened applicationHost.config in %windir%\system32\inetsrv\config. Note that in 64 bit Windows Server 2008, you'll need to edit the file with a 64 bit editor (the native Notepad will do, but Notepad++ won't be able to find the file). See here for more information about this.

In the element, change the lockItem attribute on all modules to false.

In my web application's web.config file, was then able to do the following:

<system.webServer>
   <modules>
      <clear />
   </modules>
</system.webServer>

Of course, as Scott points out, this means there's no web server left, so here is the minimum set of modules I needed to get my stuff running again (YMMV):

<add name="HttpRedirectionModule" lockItem="false" />

<add name="StaticFileModule" lockItem="false" />

<add name="CustomLoggingModule" lockItem="false" />

<add name="CustomErrorModule" lockItem="false" />

<add name="IsapiModule" lockItem="false" />

<add name="AnonymousAuthenticationModule" lockItem="false" />

Also, for anyone interested, here's the backstory as to why I'm doing this.

share|improve this answer

Scott, can you append this into your answer?

Here is what I did based on what Scott said:

  1. Opened applicationHost.config in %windir%\system32\inetsrv\config. Note that in 64 bit Windows Server 2008, you'll need to edit the file with a 64 bit editor (the native Notepad will do, but Notepad++ won't be able to find the file). See here for more information about this.

  2. In the <system.webServer> element, change the lockItem attribute on all modules to false.

  3. In my web application's web.config file, was then able to do the following:

    <system.webServer>
       <modules>
          <clear />
       </modules>
    </system.webServer>
    
  4. Of course, as Scott points out, this means there's no web server left, so here is the minimum set of modules I needed to get my stuff running again (YMMV):

    <add name="HttpRedirectionModule" lockItem="false" />

    <add name="StaticFileModule" lockItem="false" />

    <add name="CustomLoggingModule" lockItem="false" />

    <add name="CustomErrorModule" lockItem="false" />

    <add name="IsapiModule" lockItem="false" />

    <add name="AnonymousAuthenticationModule" lockItem="false" />

Also, for anyone interested, here's the backstory as to why I'm doing this.

share|improve this answer
    
Sorry about the formatting on that last bit... for some reason it wouldn't display it in normal "code" format. –  Daniel Schaffer Oct 9 '09 at 16:04
    
Sure thing. Just added it. –  Scott Forsyth - MVP Oct 9 '09 at 17:14

I hope it is not too late to help.

I got this issue today and fix the problem editing de following ApplicationHost.Config XML node:

httpErrors lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath"

Remove that ",defaultPath" and restart you IIS (iisreset).

I hope its helpfull.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.