I have an app I'm building in which I'll be using a database to display items from a Diner Menu. The menu needs to be updatable by the owners. So, I want to use web pages for this and that's no problem, but I'd like to be able to put the ability to update,
delete, and revise the pages in a folder under the root and then have the owners login. Is this possible and are there any links that explain this well?
I noticed in the Starter kit there's a login feature, but it looks like it's used for all of the pages? I'm new to this and haven't had the chance to really dig in, so I thought I'd ask what's the best approach and wondering what you folks would recommend?
For ASP.NET a logged in user dont more likely to be like Afzaal Ahmad Zeeshan its like WebSecurity
WebSecurity.IsAuthenticated is used to tell the pages and server that the user is logged in. Its done only when you log in through a login page the admin provides. Now you have to check whether user is logged one or just a robot. You can use an if..else
block as
if(!WebSecurity.IsAuthenticated) {
// Redirect them to somewhere else. Or change the form content. bla bla what ever..
}
This will be done when the user is not logged in. You can make a login page. And in the block you can write it as
DotNetTim
Member
384 Points
136 Posts
Protect a Directory and Login questions
Nov 08, 2012 06:07 PM|LINK
Hi folks.
I have an app I'm building in which I'll be using a database to display items from a Diner Menu. The menu needs to be updatable by the owners. So, I want to use web pages for this and that's no problem, but I'd like to be able to put the ability to update, delete, and revise the pages in a folder under the root and then have the owners login. Is this possible and are there any links that explain this well?
I noticed in the Starter kit there's a login feature, but it looks like it's used for all of the pages? I'm new to this and haven't had the chance to really dig in, so I thought I'd ask what's the best approach and wondering what you folks would recommend?
Should I use the Appstart?
Thanks Tim
Mikesdotnett...
All-Star
154818 Points
19853 Posts
Moderator
MVP
Re: Protect a Directory and Login questions
Nov 08, 2012 08:46 PM|LINK
You can find out how to use security from these tutorials: http://www.asp.net/web-pages/tutorials/security
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
ayanmesut
Member
219 Points
85 Posts
Re: Protect a Directory and Login questions
Nov 09, 2012 10:16 AM|LINK
You can give 'Admin' role to the owners. Put your files which you need to protect in the Admin folder.
(For that, you need 2 tables in database. 'CreateRole' is to create roles, 'AddUsersToRoles' is to add users to roles.)
Create a '_PageStart' file and write the following code:
@{ if(!Roles.IsUserInRole("Admin")){ Response.Redirect("~/"); } }As you can understand from the code that the users who do not have 'Admin' role, will be directed to the Default page.
Afzaal.Ahmad...
Contributor
2660 Points
1039 Posts
Re: Protect a Directory and Login questions
Nov 12, 2012 02:48 PM|LINK
For ASP.NET a logged in user dont more likely to be like Afzaal Ahmad Zeeshan its like WebSecurity
WebSecurity.IsAuthenticated is used to tell the pages and server that the user is logged in. Its done only when you log in through a login page the admin provides. Now you have to check whether user is logged one or just a robot. You can use an if..else block as
if(!WebSecurity.IsAuthenticated) { // Redirect them to somewhere else. Or change the form content. bla bla what ever.. }This will be done when the user is not logged in. You can make a login page. And in the block you can write it as
if(!WebSecurity.IsAuthenticated) { Response.Redirect("~/Login"); }I considered your login page to be available at this url.
~~! FIREWALL !~~
DotNetTim
Member
384 Points
136 Posts
Re: Protect a Directory and Login questions
Nov 14, 2012 06:40 PM|LINK
Thanks everyone. I found the examples after I asked, and I apologize for that. I appreicate the answers.
Tim