.

URLmappings

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.Configuration;
namespace bitlink.Core
{
    public class URLmappings
    {
        public static bool AddUrlMapping(string NewVirtualPath, string RealPath)
        {
            HttpContext CurrentContext = HttpContext.Current;
            bool exists = false;
            Configuration config = WebConfigurationManager.OpenWebConfiguration
    (CurrentContext.Request.ApplicationPath);
            UrlMappingsSection section = (UrlMappingsSection)config.GetSection
    ("system.web/urlMappings");
            foreach (UrlMapping mapping in section.UrlMappings)
            {
                //loop
                if (mapping.Url.Equals(NewVirtualPath))
                {
                    exists = true;
                    return false;
                }
            }
            if (!exists)
            {
                section.UrlMappings.Add(new UrlMapping(
                     NewVirtualPath, RealPath));
                config.Save();
                return true;
            }
            return false;
        }
    }
}

What's your thoughts on this?

*

Protected by WP Anti Spam