views:

13

answers:

1

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.

A: 

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."

handsofaten
Yes, that is the problem I am describing. Sorry I wasn't clear. So, from what you are saying I can start to use routing instead of session to store IDs to keep from the problem from happening. It surprises me that I cannot find any info about this approach anywhere so I'm a bit hesitant to use it. You did answer my main question about the possibility of having multiple routing information, i.e. invoices and line items. Thanks.
Sean
No problem... is there a reason you don't want to use hidden form fields? This is the normal way of doing it.
handsofaten
I have several pages that all relate to an invoice. For example, invoice summary, invoice line items, invoice notes, invoice documents, etc. So, I need a way to persist the invoice ID over multiple pages, so I do not have a single form where I can have hidden fields.
Sean