1

I have a guid that links the current customer to the company they are logging into.

What is the best way to pass this information between each view that is consistent and easy to retrieve at the Controller? I only need this at the controller since I'm passing it in with each query to my service.

I thought that storing it by cookie upon logon but I wasn't sure.

I am using the SqlMembershipProvider, can I store it within that class?

Any input would be greatly appreciated!

tereško
  • 58,060
  • 25
  • 98
  • 150
ErocM
  • 4,505
  • 24
  • 94
  • 161

4 Answers4

2

Use session if you need the GUID during normal page views; this keeps the cookie payload a little lighter. I usually keep a lightweight representation of the current user in memory, e.g. user ID, company ID, etc.

If you want the GUID for async operations (like JavaScript calls from widgets in your page to a WCF endpoint), consider using a cookie instead of session. This will avoid blocking issues with serial session access (see "Concurrent Requests and Session State")

Tim M.
  • 53,671
  • 14
  • 120
  • 163
1

I went with this answer:

MVC Handling a CorpId for the site

I asked it a better and in a more detailed manner.

Community
  • 1
  • 1
ErocM
  • 4,505
  • 24
  • 94
  • 161
0

One way you can do it is to use the Profiles functionality and create a profile for a user. This stackoverflow question will explain how to use it in MVC.

Community
  • 1
  • 1
Roland
  • 972
  • 7
  • 15
0

To store user related information, consider using Session variable...

HttpContext.Current.Session
Adil
  • 3,248
  • 1
  • 22
  • 27