开发者

Develop a web application framework in C#

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 = "john.smith@emailaddress.com"

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 = "test@case.com"
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


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_State_Transfer

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


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


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:

  • Primary

Others:

  • System.Web.Routing with WebForms sample

  • Use Routing with Web Forms

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜