Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a web framework in C# without ASPX?

I've managed to get a C# asp page running under ubuntu/apache/mono, but I don't want to write my framework in these ASP pages, I want to use straight C# and then I'll use a templating language for my views. But I don't know where to begin?

C# is a compiled language, so... how would I do this? Would I compile everything and then have apache hook into the (single) executable and pass in the the request URL? Could I request specific .cs pages and then have apache tell it to compile and then "display" it only if it's been updated? Can the "view" files be compiled individually to avoid having to recompile everything every time there's a change? Is there some "base" I can work from, or am I going to have to reinvent accessing GET and POST variables (by reading header info) and all sorts of other stuff we take for granted in languages like PHP?

like image 795
mpen Avatar asked May 29 '10 23:05

mpen


2 Answers

AFAIK there's no reason you can't do what you want on top of the ASP.NET core, using things like HttpApplication, HttpHandler etc. For example, you could route all URLs to a single HttpHandler and take it from there manually.

I suggest taking a look at how ASP.MVC does it - create a new ASP.NET MVC project in MonoDevelop, look at the Global.asax.cs, open the Web.config and look at the custom http handlers and modules it registers. ASP.NET MVC is OSS so you can dig around in that too.

like image 129
Mikayla Hutchinson Avatar answered Oct 01 '22 14:10

Mikayla Hutchinson


If you're really adverse to using ASP at all, you could try reading the source code for ASP and see how they implement the features you're going to need, like accessing POST and GET information, routing, session management, etc.

However, that will be a tonne of work. What you could do is implement the vast majority of your logic in c# class libraries, and just use ASP to "host" the application, and pass through the data you require.

like image 38
Josh Smeaton Avatar answered Oct 01 '22 13:10

Josh Smeaton