How to Map Paths in ASP.NET Non-Form Class File
<p>I've been using the following code in my Web form code-behind classes. I want to use it in my regular .cs files: for example, when making database calls. But when I try to use it outside of a Web form I get the following error when attempting to map with base.Request.ApplicationPath: 'object' does not contain a definition for 'Request'. What would be the simple, correct way to map to the root in a regular .cs class file in a Web Application Project?</p>

<pre><code>    protected void LogError(string errMsg, string errTrace)
    {
        string mailSubject = "oops!";
        string mailBody = errMsg + errTrace;

        System.Configuration.Configuration config
            = WebConfigurationManager.OpenWebConfiguration(base.Request.ApplicationPath);
        AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("appSettings");

        // Extract values from the web.config file
        string toAddress = "me@gmail.com";
        string fromAddress = appSettings.Settings["FromEmailAddr"].Value;
        string emailHost = appSettings.Settings["EmailHost"].Value;

        mailProvider.SendMail(fromAddress, toAddress, mailSubject, mailBody.ToString());
    }
</code></pre>
