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?

0

1 Answer 1

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(...)
}
Sign up to request clarification or add additional context in comments.

2 Comments

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.
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.