1

I have asp mvc site www.mysite.com. I want to create controller with method, that returns view on specific url - register.mysite.com. I want to create hidden section of mysite for admins to add new data into site DB. How i can do id?

tereško
  • 58,060
  • 25
  • 98
  • 150
isxaker
  • 8,446
  • 12
  • 60
  • 87

1 Answers1

1

You can't really 'hide' sections of your site, other than not providing a link to it.

Main points

  1. protect the section with [Authorize(role="Admins")]
  2. Somewhere in one of your Views, provide a conditional Link to it.

Point 1) is the real security.

Point 2) would best be done in a Child Action that creates a Model for your menu. Second choice is something like this:

@if(User.IsInRole("Admins")) 
{
   @Html.ActionLink(...)
}
H H
  • 263,252
  • 30
  • 330
  • 514
  • mysite is only shown information from db, users can't register and don't have any account. But admins may login on site and add new data to db. – isxaker Sep 28 '13 at 11:40
  • Account was just an example, put constraints on all your editing Controllers. For the subdomain, see the linked duplicate. But note that you can always create a separate App for the subdomain. – H H Sep 28 '13 at 11:42