0

So I am using the SignalR to create a chat application. I have a single page chat working Ok, but I need to implement the login so that only users can chat, and non-users get redirected to login page. Basically if you don't have a login I want you only to be able to get to the login page.

This tutorial shows how to setup login, but it doesn't go into how to restrict access to pages.

Bonus points if you point me in the right direction for grabbing the username from JavaScript for the chat.

Brendan Green
  • 11,676
  • 5
  • 44
  • 76
Nathan
  • 229
  • 5
  • 14

1 Answers1

1

Sounds like you want the [Authorize] attribute. Check out this older post on S.O. and this MSDN post to get you started.


Decorate your controller or action with the attribute like this

[Authorize]
public class AccountController : Controller
{
    //only authorized users can access this controller        
}
Community
  • 1
  • 1
Ju66ernaut
  • 2,592
  • 3
  • 23
  • 36
  • I found it just before, thanks :P. I have more questions, but i'll dig around some more first – Nathan Aug 10 '15 at 01:42