by pietman
31. May 2009 18:40
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;
}
}
}
7953c4b0-893f-4f75-9a9a-0b46a25550eb|0|.0
Tags:
c#