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#
by pietman
29. May 2009 18:35
an example of how to use an inline sort function with a delegate to define the sort process
public static List<Container.Speciality> getSpecialties()
{
Kingsweb2DataAccess.Kingsweb2DataClassesDataContext newdb =
new Kingsweb2DataAccess.Kingsweb2DataClassesDataContext();
List<Container.Speciality> res =
new List<Kingsweb2DataAccess.Container.Speciality>();
var x = from m in newdb.specialities select m;
foreach (Kingsweb2DataAccess.speciality xx in x)
{
res.Add(new Kingsweb2DataAccess.Container.Speciality(xx.Id));
}
res.Sort(delegate(Kingsweb2DataAccess.Container.Speciality a,
Kingsweb2DataAccess.Container.Speciality b)
{ return a.Specialityname.CompareTo(b.Specialityname); });
return res;
}
27fc72dd-e264-447b-902f-78586a056925|0|.0
Tags:
c# | Generics
by pietman
29. May 2009 14:06
Open your Global.Asax file
If you don't have one ....
right click on your project / website and:
add -> new item -> application configuration file
public override void Init()
{
base.Init();
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
}
a756fe33-67d1-4500-940c-86bf5a9c8237|0|.0
Tags:
c#