[英]Should I use temporary database objects instead of sessions for Web API?
I'm working with MVC and Web API. 我正在使用MVC和Web API。 I'm trying to make a simple food recipe and wants the user to be able to add Ingredients, Instructions and Images.
我正在尝试制作一个简单的食物食谱,希望用户能够添加配料,说明和图像。 I do this by doing ajax calls to the Web Api and build a temporary Recipe object with the help of sessions.
我通过对Web Api进行ajax调用并在会话的帮助下构建一个临时Recipe对象来实现此目的。
Now I understand that sessions should be avoided because of RESTful API. 现在,我了解由于使用RESTful API,应避免使用会话。 Is it better to create a RecipeTemp object with an expiration date och add this to my Context?
最好创建一个带有到期日期的RecipeTemp对象,然后将其添加到我的Context中? And then use stored procedures to delete the objects?
然后使用存储过程删除对象?
I see a lot of solutions to your problem. 我看到了很多解决您问题的方法。 It would be ok to use temp db objects if you want to give a user a possibility to change the same recipe on different devices (or if you want to give a user access to a recipe for a long time).
如果希望使用户可以在不同设备上更改同一配方(或者如果希望长时间使用户访问配方),则可以使用temp db对象。 For other cases, it's enough to use state on a client (like localStorage).
对于其他情况,在客户端(例如localStorage)上使用状态就足够了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.