[英]How to add web service layer to web application in ASP.Net
We have an ASP.Net Web Forms application in which we have different folders for Data Access layer objects, Business logic layer objects and presentation layer objects (web forms). 我们有一个ASP.Net Web窗体应用程序,其中有用于数据访问层对象,业务逻辑层对象和表示层对象(Web窗体)的不同文件夹。 We have also implemented Provider model for Sql server. 我们还为Sql服务器实现了Provider模型。 The entire application today is a unified dll file, with the web forms. 今天的整个应用程序是带有Web表单的统一dll文件。
We have to now deliver a separate web application which will be accessed as an extranet to this application. 我们现在必须交付一个单独的Web应用程序,该Web应用程序将作为此应用程序的外部网访问。 We are thinking of implementing it as a presentation layer application with calls to web services (for additional security) rather than connecting to the database directly. 我们正在考虑将其实现为表示层应用程序,以调用Web服务(以提高安全性),而不是直接连接到数据库。 We are faced with the following considerations: 我们面临以下考虑:
Is there a way to use (re-use) the business logic already implemented in the application without copying the source code in a web service component? 有没有一种方法可以使用(重用)已经在应用程序中实现的业务逻辑,而无需在Web服务组件中复制源代码? This would make maintenance more easy since fixing the business logic and data access logic in the application will automatically be effected in the extranet application. 由于将在Extranet应用程序中自动实现在应用程序中修复业务逻辑和数据访问逻辑,这将使维护更加容易。
We are using forms authentication today. 我们今天正在使用表单身份验证。 Is there a way for the extranet application to also use the same user, membership, roles and profile for the extranet, so all users can be administered from the existing application? Extranet应用程序是否可以对Extranet使用相同的用户,成员身份,角色和配置文件,以便可以从现有应用程序管理所有用户? Will this authentication be treated as a web service? 将此身份验证视为Web服务吗?
Another approach would be of course to expose the web service from the very same application that hosts your existing presentation layer. 当然,另一种方法是从托管您现有的表示层的同一应用程序中公开Web服务。
context.User
from within the web service code just as you do it in your web app code. 如果您使用表单身份验证来保护Web服务,则服务器将期望格式良好的表单cookie,然后您就可以从Web服务代码中访问context.User
,就像在Web应用程序代码中一样。 Years ago I've blogged on how to share forms authentication between a web app and a desktop/web service app. 几年前,我写了一篇关于如何在Web应用程序与桌面/ Web服务应用程序之间共享表单身份验证的博客。
http://www.wiktorzychla.com/2008/02/clickonce-webservice-and-shared-forms.html http://www.wiktorzychla.com/2008/02/clickonce-webservice-and-shared-forms.html
Some time later, I've updated the topic with another entry on how to do the same for WCF 一段时间后,我用关于如何对WCF进行相同操作的另一个条目更新了该主题。
http://www.wiktorzychla.com/2010/04/aspnet-forms-authentication-sharing-for.html http://www.wiktorzychla.com/2010/04/aspnet-forms-authentication-sharing-for.html
This should give you the required background. 这应该为您提供所需的背景。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.