开发者

Can URL routing help with issues from multiple tabs and session storage?

开发者 https://www.devze.com 2023-01-12 07:19 出处:网络
I have an application that stores database IDs in session while editing several pages of data. When the user opens multiple tabs (or windows), data is being overwritten because the IDs are getting cro

I have an application that stores database IDs in session while editing several pages of data. When the user opens multiple tabs (or windows), data is being overwritten because the IDs are getting crossed up. I completely understand the problem, and was going to fix this by taking the IDs out of storage and passing them around in query string; however, I thought URL routing might be a better solution. For example, I could have a URL of .../Invoice/123.

My biggest concern is that there are multiple IDs I need at one time. For example, an invoice might have a list of line items, so开发者_运维知识库 I'd have to use a URL with .../Invoice/123/LineItem/456. Can someone let me know if this is possible with routing?

Also, are there other concerns I should have or reasons this is a bad idea? The original problem I'm describing was in a former post labeled "Way around ASP.NET session being shared across multiple tab windows" if I wasn't clear above. Thanks in advance.


If I understand you correctly, the problem is that you are storing information about which record a user is editing in the session, but some users are opening multiple tabs and thus screwing up your assumption that they would just be editing one record at a time.

I've not used ASP.NET, but with the MVC frameworks I've used, there is no problem with using the invoice/123/lineitem/456 URL approach. Invoice would be the main controller you are working in, and 123, lineitem, 456 would all be variables passed into it. You just have to make sure you know exactly which (and how many) variables you need to pass in and map them out.

Since your question is pretty vague, I have no idea how you are using this, but the simplest solution is probably to use hidden form fields with, for example, the name "lineitem" and the value "456."

0

精彩评论

暂无评论...
验证码 换一张
取 消