ASP.NET web application architecture design advice

自古美人都是妖i 提交于 2019-12-03 10:04:01

If you only think there is a benefit, you should not do it. You are talking about adding a large amount of complexity and work for yourself, at the cost of performance, code simplicity, and architectural simplicity, for... what? What do you gain that's worth these costs?

Do you:

  • Have urgent security-related needs that require disconnecting the web front-end from the database server (no, not hypothetical "I bet this would be more secure" but demonstrable, concrete security problems which cannot be solved by being smart about what DB rights you grant your ASP.NET application)

  • Expect to swap your data tier out completely at some point in the future (probably repeatedly), and thus need to insulate your web codebase from radical DB changes?

The answer to these in very nearly every case is no. Doing this would just be adding pain for yourself and anyone else who might touch this app.

Regarding your question #2 - you can most certainly return a DataSet from a web service. http://tinyurl.com/ah58xc

However, perhaps a better option would be to simply refactor your application instead of making it into a multi-tier. For example, separate the "data access" into a separate Class Library project that you reference from your ASP.NET project. This could make things more organized and might possibly accomplish some of what you're wanting to do with the multiple tier architecture.

By the way, the biggest danger in creating multiple tiers when you might not necessarily need them is that you end up creating "proxy" code, for lack of a better term. That is, methods that serve no purpose other than to call the "real" back-end methods with the same parameters. This feels better at first because you have a clean layer separation but leads to maintenance problems down the road, because, for example, to add a parameter to a method, you have to add it 3 times (back-end, proxy layer, and presentation layer).

My first question is: Why a web service in the middle? If this is all going to run on the same physical machine, then you may want to refactor a middle tier that is used through a set of interfaces and using direct method calls.

I am working on an architecture that is seperated with a middle-tier web service, but it contains all the company critical business logic, and will not be directly exposed to the internet. Something like:

{internet} -> |DMZ| -> Web server -> |Firewalled LAN| -> App server -> Database server

In that case, I do think it adds a layer of security, as the mission critical stuff isn't on the DMZ. Granted it still technically violates some security issues because the web server can contact the app server, but having the app server exposed through a single port to a specific IP in the DMZ is better than having it exposed to the internet.

If you are going to use WCF to communicate between the servers, I would suggest using something like binary serialization over TCP, instead of SOAP. That should perform better (feel free to set up a quick test). I haven't tried it myself, but WCF might be able to serialize a dataset or table over the wire. See here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!