c# - Is there any way to create, compile and load dynamically an ASPX page -


ok, i'm wondering if it's possible create aspx page on fly. mean, i've done before*, knew beforehand assembly creating, , got assembly referenced in target project in advance (so repleace old new one). now, instead of this, got create files aspx page needs (aspx, codebehind , designer) , add reference reultant assembly current executing assembly can navigate page there.

so far, i've been able compile code behind (the designer seems no-brainer) assembly file, codedom, , managed load assembly dynamically. don't have clue how can access dinamically created page through assembly, , guess i'll have create .aspx file (i guess it's not possible attach .aspx generated assembly).

it might wrong approach i'm trying achieve, i'll glad if can shed light uppon :)

im adding code, if helps anyone:

codedomprovider c = codedomprovider.createprovider("csharp");              assembly executingassembly = assembly.getexecutingassembly();              compilerparameters cp = new compilerparameters();             cp.referencedassemblies.add("system.dll");             cp.referencedassemblies.add("system.web.dll");             cp.referencedassemblies.add("system.data.dll");             cp.referencedassemblies.add("system.xml.linq.dll");             cp.referencedassemblies.add("system.drawing.dll");              cp.compileroptions = "/t:library";              cp.outputassembly = "paginatal.dll";              cp.generateinmemory = false;              stringbuilder sb = new stringbuilder(""); //texto del codigo             sb.append("using system;\n");             sb.append("using system.collections.generic;");             sb.append("using system.web;");             sb.append("using system.web.ui;");             sb.append("using system.web.ui.webcontrols;");              sb.append("namespace nuevaclase{ \n");             sb.append("public partial class nuevaclase : system.web.ui.page { \n");             sb.append("public string yuhuu(){\n return \"yuhuuuu\";\n }\n");             sb.append("protected void page_load(object sender, eventargs e){\n");             sb.append("");             sb.append("} \n");             sb.append("} \n");             sb.append("}\n");  compilerresults cr = c.compileassemblyfromsource(cp, sb.tostring());              if (cr.errors.count > 0)             {                 console.writeline("error");             }              assembly = cr.compiledassembly;             assembly.loadfrom(a.location); 

*what did creating 3 files: .aspx, aspx.cs , aspx.cs.designer; , referencing them manually in .csproj file, compile msbuild assembly , move substitute former assembly in target project. this, believe or not, worked perfectly, thought not proper approach , i'm trying other way around told before.

it might wrong approach i'm trying achieve,   i'll glad if can shed light uppon :) 

i think miss goal.

what goal: show information's, output response.

for use asp.net programmatically create output.

what try is: create page, create second page, make output. why ? why not direct use asp.net programming show output , information's, why ? name on top of page wish change ?.

the minus make page that.

  1. possible bugs can not handle
  2. every time make new page, compiler may recompile full site, or part of site.
  3. is possible create conflict class crash system.

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -