if (HostingEnvironment.VirtualPathProvider.FileExists(virtualPath)) { Type compiledType =null; try{ //Compiles a file given its virtual path and returns the compiled type. compiledType = BuildManager.GetCompiledType(virtualPath); if (compiledType ==null){ //Processes a file given its virtual path and creates an instance of the result. object page = BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(System.Web.UI.Page)); compiledType = page.GetType(); } }