We are creating a MVC4 document retrieval site where some documents require authentication, while other documents allow anonymous access.
The URL includes a folder id that is used to retrieve a list of documents. Sometimes none of the documents require authentication, sometimes all the documents do, and sometimes it is a mix.
How would I approach this? Thanks in advance.
I would add a
bool RequiresAuthenticationitem to your database table that contains the documents. This would befalseif the document is free (no auth needed) andtrueif not.Then you could do something like this in the controller that serves the documents.
You could even pass a
returnUrlto the log on so once the user logs on they are redirected back to the document they wanted.