Search This Blog

Sunday, February 28, 2010

Path to current website directory in ASP.NET

I'm working on a standard name/address web app for permitting users to update their personal information.

The client wants to provide forced-choice options for certain fields in the active directory user object. He gave me some Excel files that I changed to XML files which the dropdown controls on the web form access. For example, he wants people to choose their "Department" field from a fixed list. Simple enough.

To improve the look/feel of the app I needed to have the webpage code to actually read that XML file to do a lookahead and pre-load a dropdown list position, but it was difficult to tell the codebehind code where exactly to look.

The solution was to preface the name of the XML file that I needed to read with the value "Request.PhysicalApplicationPath" -- that points it directly into the directory on the web server.