So I've been kicking around how to create a web application running on .Net and applicable servers(IIS, xsp, etc) WITHOUT using a Webforms or MVC, and I've just now made a mini victory.
I now have a very minimal application running and it runs on both Mono and .Net. First off, I added a new ASHX handler named Test1.ashx
I went ahead and deleted all of the code from the class and put this bit in it:
protected virtual void Application_BeginRequest (Object sender, EventArgs e)
{
if(Request.Url.AbsolutePath=="/test"){
var h=new Test1(); //make our Test1.ashx handler
h.ProcessRequest(Context);
}else{
Response.ContentType="text/plain";
Response.Write("Hi world!");
}
CompleteRequest();
}
And then in my Web.config I removed a huge amount of junk. It ended up looking like this in the end:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true">
</compilation>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
</system.webServer>
<runtime>
</runtime>
</configuration>
ahh, the best web.config is a short one.
Put it all together and run it, and poof it works as you'd expect. One thing I'm trying to figure out now is how error pages work and why CompleteRequest(); is required at the end of the BeginRequest.
I'll probably put this in an SVN repo pretty soon and I'll post a link to it when I do..
Comments
Post a comment!