« Previous Next »

Thread: Rewrite Condition Is Directory

Last post 01-27-2009 6:40 PM by wimoy. 5 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (6 items)

Sort Posts:

  • 01-26-2009, 4:36 PM

    • Kanien
    • Top 75 Contributor
    • Joined on 01-31-2008, 12:14 AM
    • Posts 104

    Rewrite Condition Is Directory

    I am implementing the Rewrite module w/IIS7 and I wanted to know if there is a way to use the Is a Directory condition at the global level? 

     I am asking because it is possible that the web.config in the webroot be overwritten by accident and the rewrite no longer function.

     Thanks!

  • 01-26-2009, 7:44 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 661

    Re: Rewrite Condition Is Directory

    It is not possible to use IsDirectory in a rule defined on a global level (<globalRules>). However, you can place site specific rules in the applicationHost.config file and configure IIS delegation so that it is not possible to overwrite the rules in web.config file.

    http://ruslany.net
  • 01-27-2009, 11:21 AM In reply to

    • Kanien
    • Top 75 Contributor
    • Joined on 01-31-2008, 12:14 AM
    • Posts 104

    Re: Rewrite Condition Is Directory

    Thanks for the quick reply Ruslan.

     Furthermore I am interested in how the following scenario would be played out as I will have to add these lines to the site section of the applicationHost.config file in real time as they are requested.  Let's say one of my services attempts to make the change to the applicationHost.config file for the Rewrite rules, while another one of my services is using appcmd to modify a site, and I have the Inetmgr open or the applicationHost.config open in a text editor such as notepad.  What are my potential conflicts in file access?

  • 01-27-2009, 6:11 PM In reply to

    • wimoy
    • Not Ranked
    • Joined on 01-23-2008, 9:44 PM
    • Posts 9

    Re: Rewrite Condition Is Directory

    Hi Kanien,

    All of our administration tools ultimately use the same module, nativerd.dll, to make configuration changes. This module checks the timestamp of the configuration file being written to before making any modifications to the file and aborts the commit operation if it detects that the file has been changed since it was last accessed. The resulting effect of this safeguard is that when there are multiple simultaneous configuration write operations through this module, only the changes corresponding to the first operation to call commit will be written on disk. How the failures from the subsequent commits are handled is specific to the application using the module but most will simply surface the error without attempting to reapply the changes.

    You can use this module by using our managed configuration API, Microsoft.Web.Administration, or our COM configuration API, Microsoft.ApplicationHost.WritableAdminManager. If your service is using one of these APIs, it will have that behavior. Since notepad does not use our configuration module and simply writes to the file directly, executing "Save" will overwite the configuration file with whatever is in notepad without regard for changes that may have been made to the file since the file was opened in notepad.

    I hope this helps.

    Thanks

  • 01-27-2009, 6:31 PM In reply to

    • Kanien
    • Top 75 Contributor
    • Joined on 01-31-2008, 12:14 AM
    • Posts 104

    Re: Rewrite Condition Is Directory

    It does help.  I know you wrote "all of your administration tools" and please excuse my ignorance, but what about appcmd?  I use it very often and even use it in my scripts.  Do multiple appcmds running at the same time pose a conflict?

  • 01-27-2009, 6:40 PM In reply to

    • wimoy
    • Not Ranked
    • Joined on 01-23-2008, 9:44 PM
    • Posts 9

    Re: Rewrite Condition Is Directory

    Hi Kanien,

    Appcmd does use nativerd.dll so the behavior I mentioned applies. However since appcmd is usually short-lived it is unlikely that it will conflict with itself. If you do, you will be presented with an error similar to this:

    Applied configuration changes to section "system.webServer/defaultDocument" for
    "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"

    ERROR ( hresult:80070020, message:Failed to commit configuration changes.
    The process cannot access the file because it is being used by another process.
     )

Page 1 of 1 (6 items)
Microsoft Communities