I'm searching my assembly (using System.Reflection
) for classes that are inherited from a specific class (System.Web.UI.Page
).
All these inherited classes have pages in my web.
How can I read .aspx
file path too (relative to web root)?
I know I can read this path from .pdb
file, however this file does not exists in live server.
Edit to avoid confusion, here is a sample of my code. doSomeProcess is not exact process. in fact it receives the class itself and analyzes it too. however it is not important for this code sample.
using System;
using System.IO;
using System.Reflection;
namespace ... {
public class FixPaths: System.Web.UI.Page {
void SearhcAssembly(){
Assembly library = Assembly.GetExecutingAssembly();
string FileName = Path.GetFileName(library.Location);
foreach (Type type in library.GetTypes()) {
if (FileName == type.Module.Name) {
if (type.BaseType != null && (type.BaseType.FullName == "System.Web.UI.Page")) {
string NameSpace = type.Namespace;
string ClassName = type.Name;
// -- This need to be changed --
string PageUrl = "/" + type.Namespace.ToLower().Replace(".", "/") + "/" + type.Name + ".aspx";
// -------------------------------------
doSomeProcess(NameSpace, ClassName, PageUrl);
}
}
}
}
}
}