简体   繁体   English

我应该使用临时数据库对象代替Web API的会话吗?

[英]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.

相关问题 我应该使用会议吗? - Should I use sessions? 我可以(或应该)使用 IAsyncEnumerable<T> 而不是任务<ActionResult<IEnumerable<T> &gt;&gt; 在 Web API 控制器中 - Can (or should) I use IAsyncEnumerable<T> instead of Task<ActionResult<IEnumerable<T>>> in a Web API Controller 我应该在API上公开接口而不是具体的对象吗? - Should I expose interfaces instead of concrete Objects on my API? 我应该使用Azure移动服务还是坚持使用Web Api - Should I use Azure Mobile Services or stick with Web Api 处理Web API的会话 - Handling sessions to web api 我应该使用什么来临时存储将被重用的XML数据? - What should I use to temporary store XML data that will be reused? Azure Web API 访问:我应该使用哪个 URL,Web 服务 URL 还是网关 URL? - Azure Web API Access: Which URL should I use, the Web Service URL or Gateway URL? 在使用Linq-to-SQL进行浮点运算的数据库和对象中应该使用哪种类型? - What type should I use in Database and Objects using Linq-to-SQL for floating point? 我为什么要使用IHttpActionResult而不是HttpResponseMessage? - Why should I use IHttpActionResult instead of HttpResponseMessage? 我应该使用什么代替SQL“ OR”语句 - What should I use instead of SQL “OR” statements
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM