Hi, I'm using this class to parse aspx files, it's currently working on the microsoft side, but not on mono. No error is shown as I run the parser, another thing to notice is, if a non existing aspx file is passed, no error occurs either.
I'm using: mono-1.1.6-installer.bin and this is what I'm doing: PATH=$PATH:/opt/mono-1.1.6/bin mcs -r:System.Web monotest.cs mono monotest.exe $(pwd) test.aspx See files attached here... Also, I should explain better. I'm using aspx files as templates for a code generator I'm running. There's no need for IIS. It's working fine in windows and I'm trying to port it to mono, apparently this is the only thing I'm having trouble with. Many thanks, in advance: Francisco
test.aspx
Description: Binary data
using System;
using System.Web;
using System.Web.Hosting;
using System.IO;
using System.Text;
using System.Collections;
namespace monotest {
class MainClass {
[STAThread]
static void Main(string[] args) {
if (args.Length != 2) {
Console.WriteLine("monotest.exe appPath
aspxFile");
} else {
Console.WriteLine(cAspxParser.PageParse(args[0], args[1]));
}
}
}
class cAspxParser { private cAspxParser() {}
private class HttpRuntime_Wrap : MarshalByRefObject {
public void ProcessRequest(string aspxFile_in,
TextWriter textwriter_in) {
HttpRuntime.ProcessRequest(
new SimpleWorkerRequest(aspxFile_in,
string.Empty, textwriter_in)
);
//textwriter_in.WriteLine("step4: {0}",
aspxFile_in);
}
}
public static string PageParse(
string appPath_in,
string aspxFile_in
) {
const string domainId_ = "test";
const string ApplicationName_ = "test";
const string appVirtualPath = "/";
const string hostingVirtualPath = "/";
if (appPath_in[appPath_in.Length - 1] !=
System.IO.Path.DirectorySeparatorChar)
appPath_in +=
System.IO.Path.DirectorySeparatorChar;
StringBuilder _stringbuilder = new StringBuilder();
StringWriter _stringwriter = new
StringWriter(_stringbuilder);
AppDomainSetup _appdomainsetup = new AppDomainSetup();
_appdomainsetup.ApplicationName = ApplicationName_;
AppDomain _appdomain = AppDomain.CreateDomain(
domainId_,
null,
_appdomainsetup
);
_appdomain.SetData(".appDomain", "*");
_appdomain.SetData(".domainId", domainId_);
_appdomain.SetData(".appPath", appPath_in);
_appdomain.SetData(".appVPath", appVirtualPath);
_appdomain.SetData(".hostingVirtualPath",
hostingVirtualPath);
_appdomain.SetData(".hostingInstallDir",
HttpRuntime.AspInstallDirectory);
HttpRuntime_Wrap _server =
(HttpRuntime_Wrap)_appdomain.CreateInstance(
typeof(HttpRuntime_Wrap).Module.Assembly.FullName,
typeof(HttpRuntime_Wrap).FullName
).Unwrap();
//_stringwriter.WriteLine(string.Format("step1: {0}",
appPath_in));
//_stringwriter.WriteLine(string.Format("step2: {0}",
aspxFile_in));
//_stringwriter.WriteLine("step3");
_server.ProcessRequest(
aspxFile_in,
(TextWriter)_stringwriter
);
//_stringwriter.WriteLine("step5");
_stringwriter.Close();
return _stringbuilder.ToString();
}
}
}
