MVC - Implement members online functionality - asp.net-mvc

I have an ASP.NET MVC app and I want to add
to each page a list of members online. Actually add to Master page.
Members belong to groups so I want to
show all members in there groups.
So what is the best way of doing this??
Eg On session start add to a collection that is in cache object
and remove it on session end in Global.asax.
Is that a reliable way??
Traffic wont be enormous.
Malcolm

See How can I determine the number of users on an ASP.NET site (IIS)? And their info? The same approach can be used for WebForms as well as ASP.NET MVC.

Yes, you'll have to use the Application object to store it,
and you could do it in the Session Start/Session End events.
Add to the Application on Start, and remove on End.

Related

Authenticatnig ASP.NET MVC application against Sitecore users

I just started to working in Sitecore. I am developing a web application in ASP.NET MVC 5.0 to create / edit some content in Sitecore. I am looking for the best way for authentication in web application (MVC) using existing Sitecore users. User management part will stay with Sitecore, just need authentication (login) in web application against Sitecore users. Can I use Identity concept of ASP.NET for the same?
Sitecore use Membership providers.
Normally create for web users a new domain. so not the same as CMS users.
See This:
http://fes-sitecore.blogspot.nl/2015/02/using-membership-with-sitecore.html
And the Documentation from Sitecore:
https://sdn.sitecore.net/upload/sitecore6/sc61keywords/membership_providers_a4.pdf
I have done this in the last few weeks.
What you will need first to to create a Role in Sitecore that your Extranet (siteusers) will get logged in against. Create a user and assign them to this role.
You will need to go to the security editor (i think) and select the 'everyone' role. Allow everything and inheritance from the top of the tree. (green cross on the content item)
For the item you wish to lock put a red cross against the inheritance
Then select your created role and put a green cross in inheritance against the item you wish to allow this role to see
From Sitecore: The idea is allow everything for everyone and break inheritance to secure it by adding a red cross to inheritance.
From the website: The idea is that everyone (siteusers) don't have access to the page and will get redirected. People in your new role will go to the page.
Next take a look at the post above but in your site settings you need a configure the location of your login page.
After these steps you should be able to navigate to the page and get redirected to your login page (Make sure you are not in the content editor)(incog mode google chrome)
So finally you can use the Sitecore.Authentication namespace and there are method on there to authenticate and check if a user is in a role ect.
Take a look at https://sdn.sitecore.net/upload/sitecore6/sc61keywords/security_api_cookbook_usletter.pdf
Hope this helps. Any questions just ask. Its hard to explain in text :)
Aki,
You can leverage the sitecore authentication which is very useful, I am using this in my all projects since sitecore 6.5 to 7.5.
you just have to explore few APIs of sitecore membership, there you will get
How to create roles
how to set users in roles.
And how to provide proper security or limited access to a particular role.
How to set custom data for users also.
Make sure you are not using sitecore domain for web users, use extranet domain. Sitecore domain is only for user who are supposed to login into sitecore dashboard.
Hope this will help you..
Cheers!!

ASP MVC 5 (Microsoft.AspNet.Identity) User Management Package

Does asp.net mvc5 really not come with some sort of default controllers and views to manage your users? things like creating a new role, and then assigning it to a user etc etc?
Is every single mvc5 website supposed to code their own?
Over and over again?
I get that we can now add custom fields etc to our users, but surely some sort of simple base built in manager isn't asking for too much?
Is there some magical nuget package or something I'm missing?
There doesn't seem to be anything like this.
I have added an item onto the asp.net uservoice list and you can vote for it there.
I'm marking this as closed.
http://aspnet.uservoice.com/forums/41201-asp-net-mvc/suggestions/5009231-add-a-default-asp-mvc-5-microsoft-aspnet-identity

Best strategy for custom profile properties in MVC 3

I need to implement some (maybe 10) custom properties for logged in users for my MVC3 vb.net web app.
These will define how certain data is displayed within my views.
I can think of a couple of possible solutions..
Session variables. Will do the job but seems a bit untidy, and
can't be strongly typed
custom properties of the current user object; is that even possible?
Custom profile provider. Looks like it might be a good option.
Has anyone got any tips on what worked well for them?
I already have custom membership and role providers that are working fine.
Thanks!
First solution - use standard ASP.NET Profile Properties feature.
If for some reasons you can't use that - then I'd vote for custom profile provider.

Hidden session Id in MVC Master Page

I have an MVC application, and I need to create and store a unique session Id for each application instance. In standard ASP.NET this is easy, I would have simply added a hidden field in the master page and stored a Guid there on the first Page_Load.
However, there is not code behind in MVC, and I also believe that you can't implement a controller for a master page OR create a strongly typed view master page.
Anyone know an easy way around this? I'm just playing around with MVC for the first time so be gentle if what I'm asking seems stupidly simple.
Thanks
If you need to persist a few objects for the lifetime of an instance of your application I would recommend you using the built-in Cache object or Application. If those objects need to be specific to each user then use the Session object.
Why not store this in a cookie?

Flatpages equivalent for ASP.Net MVC

Django has the Flatpages app, which lets site admins change content on specific pages without changing code. Flatpage content i stored in the database, sort of like in a CMS. Flatpages are typically used for about-pages and such.
Are there any good equivalents for ASP.Net MVC? I.e., a convenient way to manage page-content persisted to a database.
No.
Django seems closer to a CMS then "ASP.NET MVC" which is both a framework and just a general design pattern.
Have a look at http://http://cmsmvc.codeplex.com, it allows you to create pages, and manage content on the page.
The solution is still in early stages, but it could help you out.

Resources