我想在使用IHttpHandler方法的.Net-Project中使用XSP或更好的mod_mono。單聲道和IHttpHandler
我有下面的類(很簡單:
public class Class1 : IHttpHandler
{
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext context)
{
var result = "<h1>Yeah</h1>";
var bytes = Encoding.UTF8.GetBytes(result);
context.Response.Write(result);
}
}
而下面的web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers accessPolicy="Read, Execute, Script">
<add name="Class" path="*" verb="*" type="IISHost.Class1" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
<system.web>
<compilation defaultLanguage="c#" />
</system.web>
</configuration>
這是IIS中正常使用http://127.0.0.1/test/kfdlsa回報 '是'
在Apache上的XSP或mod_mono,我可以創建一個index.aspx,它可以根據.Net-Framework完全解析和執行,但它似乎是處理程序不是包含在mod_mono-Framework中。
正在使用IHttpHandler在Mono中真正實現,還是應該使用另一種方法將所有請求收集到某個主機和/或虛擬目錄。
塞德里克,感謝您的有用答案。我有一個類似的單一虛擬主機的問題,涉及靜態變量的生命週期,我很想你的輸入http://stackoverflow.com/questions/13480328/c-sharp-mono-linux-web-server-hosting-with-conistent - 靜態變量 - 跨 – Glenn
完美地工作!謝謝。我在獨立(而不是mod_mono)模式下使用XSP,因此在該場景中不需要apache配置,但web.config更改正是需要的。 –
如何獲取Mono.WebServer的web.config中支持或不支持的信息? – DonDon