views:

427

answers:

3

Hi,

I'm planning to develop my own simple and elegant web application framework in C# 3.5. I have some ideas, but not yet the best practice how it should be implemented. Maybe you can help?

My ideas:

  • It is a C# Library (DLL)
  • It needs to use XSLT as templating language, so XML must be the output of my data-/model-layer
  • It needs to connect to different databases, like MySQL en SQL Server and ODBC
  • It needst to be command base, like the Command Design Pattern, so I can post a command with some parameters grouped to that command and do 'stuff'
  • All commands and database actions from 1 post need to be in 1 transaction, so everything can be rolled back
  • It needs to have a security/authorisation model (what is good?)
  • It needs to have some kind of URL resolving, like /a/b/c resolves to /?id=33
  • It needs to be pluggable, so when I'm creating a web-app for someone with specific needs, I don't need to alter my base Engine Library
  • It needs to have caching and/or compression techniques inside
  • It needs to be fast and threadsafe and performing
  • It needs to have debug-logging
  • It would be nice to have some kind of dynamic scripting, like IronPython, implemented into the data-/model-layer for dynamically scripting my output to the XSLT, so adjustments can be made quickly, without entering Visual Studio and adjusting my DLL.

Would you have ideas what is the best way to start setting up such a framework? Or is there already a framework like this in C#?

This is one small idea, when you have the tables 'Customer' and 'Address', and you want to post a html-form for adding a record into the database and mail him, you need to post these fields in 1 postaction:

Customer.ACTION = add
Customer.Name = "John Smith"
Customer.Email = "[email protected]"

Address.ACTION = add
Address.CustomerId = #Customer.ResultId#
Address.Street = "Mainstreet"
Address.Number = "1"

Mail.ACTION = send
Mail.AFTER = Customer
Mail.To = #Customer.Email#
Mail.From = "[email protected]"
Mail.Subject = "Welcome"
Mail.Body = "Welcome new customer!"

The engine receives the post, and by Reflection it collect the class for the command it needs, in this case the DatabaseCommand and MailCommand and runs it. You see, I want to use some kind of queuing with sorting. In this case the Customer-command needs to be the first, after that the Mail (see the Mail.AFTER) and/or the Address (see the dependency #Customer.ResultId#).

So what are your ideas about this project?

Regards

+4  A: 

have you considered extending the MVC model rather than starting from scratch?

Not exactly sure what you're trying to do with the xslt - did you want to send it xml and have it transform back to html? if so you can try inheriting ActionResult and have this perform the transform using the standard .NET libraries.

this approach will support mysql, sql server, oracle etc as per the .NET libraries, has security/auth, can use custom routes to do your /a/b/c -> /?id=33 mappings, is OO based and can be pluggable, caching can be done as it's base is ASP.NET, and GZIP/DEFLATE compression can be enabled on IIS.

applying the xslt to the data/model layer doesn't sound like the right place for it - i'd be putting this much closer to the view layer.

regarding your POST data, you can choose to use the standard MVC way to handle this verb, otherwise it sounds like you're wanting a RESTful based architecture http://en.wikipedia.org/wiki/Representational%5FState%5FTransfer

of course you can always just inherit IHttpHandler and cause yourself a lot of pain ;)

Andrew dh
Do you mean the ASP.NET MVC (http://www.asp.net/mVC/)?I like XSLT, so that is why I want to have that as my transformation to XHTML. Then I can do anything I want an implement good strict XHTML.
hoest
I've realized some of my should-haves. But will try to think out what templating and data-output I will use.
hoest
check out the NHaml .net library. it's very nice to work with from a templating POV
Andrew dh
A: 

for the URL resolving, i recently implemented it in my existing framework. It leveraged the ASP.Net routing engine.

I could send you the module with sample codes on how to use it.

Update

Here is what really this help:

Others:

Colour Blend
That would be cool, thx!
hoest
@Colour Blend: is it possible to post that sample code?
hoest
Ok. I will do that.
Colour Blend
A: 

Hello,

There is an large amount of work involved in developing any framework( web-based or not). Consider the 2 popular web frameworks "Rails" for Ruby and "Django" for Python. They are built by a team and are quite extensive. You can build one, but it will definitely take up a lot of time.

There aren't many web frameworks out there for .NET that I'm aware of, however the following are of note(They may not all necessarily be "Web Frameworks" though):

  1. ASP.NET MVC is modeled after "Rails".
  2. SubText project
  3. SpringFramework.NET / NHibernate.NET
  4. NetTiers
  5. Castle Project
  6. Various web / frameworks on CodePlex
    • CommonLibrary.NET
    • Catharsis
    • MojoPortal
Phil M