简体   繁体   English

使用HTML5的ASP.NET服务器端逻辑和客户端2D可视化

[英]ASP.NET server-side logic and client-side 2D visualization with HTML5

I am doing some research for a project that is kicking off soon and would like some input on what options I have here. 我正在为一个即将开始的项目做一些研究,希望就我在这里的选择有一些意见。

Basically, this is more or less how it should work: The user should be able to draw certain shapes, like polygons and based on different properties, such as position etc. of the shapes, calculations are being performed on the server side and the results are sent back to the client. 基本上,这或多或少是它应该如何工作的:用户应该能够绘制某些形状(例如多边形)并基于不同的属性(例如形状的位置等),在服务器端进行计算并获得结果被发送回客户端。

I have a .NET class library that contains class representations of the shapes (circle, polygon, lines etc.) as well as all the calculations needed. 我有一个.NET类库,其中包含形状(圆形,多边形,直线等)的类表示形式以及所需的所有计算。 All this is wrapped up in a project class and serialized into a database because the user should be able to login, save his work, load it at another point in time and continue. 所有这些都包装在项目类中并序列化到数据库中,因为用户应该能够登录,保存其工作,在其他时间点加载它并继续。

All drawing should be done on the client using HTML5 Canvas and JavaScript and the business logic, such as calculation are done on server side. 所有绘图应在客户端使用HTML5 Canvas和JavaScript进行,而业务逻辑(如计算)则在服务器端进行。 The issue that I need to resolve here is the two-way communication and sharing of complex (polymorphic) objects between the client and the server and I would like to avoid having one .NET shape-class and one JavaScript shape-class because it results in redundant code. 我需要在这里解决的问题是客户端和服务器之间的双向通信和复杂(多态)对象的共享,我想避免使用一个.NET形状类和一个JavaScript形状类,因为这样会导致以冗余代码。

One possible solution would be to serialize & deserialize the classes into JSON. 一种可能的解决方案是将类序列化和反序列化为JSON。 However, the classes contains quite alot of data (most of which is not interesting for the client) and means alot of data transfered back and forth. 但是,这些类包含相当多的数据(其中大多数对于客户端而言并不重要),并且意味着大量数据来回传输。 This could be resolved using DTO classes but then I am back at having two classes containing common information. 可以使用DTO类解决此问题,但随后我又回到了两个包含公共信息的类。

Are there any other solutions/techniques to go for here? 这里还有其他解决方案/技术吗? Anyone have any experience with this type of problem? 任何人都有处理此类问题的经验吗?

Thanks in advance. 提前致谢。

Given that you're using ASP.NET (not MVC), I think adding DataContract / DataMember attributes to your existing .NET classes would be the way to go, along with a client-facing WCF service. 鉴于您使用的是ASP.NET(而不是MVC),我认为将DataContract / DataMember属性添加到现有的.NET类中以及与面向客户端的WCF服务一起使用是一种方法。 That way you can serialize existing classes into JSON, but still select which properties get serialized. 这样,您可以将现有的类序列化为JSON,但仍选择要序列化的属性。

If you're not familiar with data contract/ WCF/ AJAX stuff, this site has some good jumping-off points: http://wcf.codeplex.com/ 如果您不熟悉数据合同/ WCF / AJAX内容,则此站点有一些不错的起点: http : //wcf.codeplex.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 客户端或服务器端(asp.net)图像映射都不会弹出html表单 - Neither client-side or server-side (asp.net) imagemap will popup html form ASP.NET服务器控制服务器端/客户端上的相同事件处理顺序 - Asp.net server control same event handling order on server-side/client-side 如何在ASP.NET中从客户端调用服务器端函数? - How to call server-side function from client-side in ASP.NET? 客户端(jquery)和服务器端(asp.net)应用程序都可以访问的服务 - Service that can be accessed by both client-side (jquery) and server-side (asp.net) applications Asp.Net:在服务器端还原DropDownList的客户端SelectedItem - Asp.Net: Restoring client-side SelectedItem of DropDownList on server-side 如何填补ASP.NET webforms中服务器端和客户端之间的空白? - How to fill the gap between server-side and client-side in ASP.NET webforms? 通过ASP.NET服务器端访问客户端生成的表行 - Accessing client-side generated table rows through asp.net server-side 在客户端加密ASP.NET文本字段,并在服务器端解密 - Encrypting ASP.NET text fields at client-side and decrypting them at server-side 如何通过在ASP.NET中调用服务器端函数来应用客户端验证 - How to apply Client-side validation by calling a server-side function in ASP.NET asp.net表单验证。 服务器端或客户端 - asp.net form validation. Server-side or client-side
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM