Hi all, I am still a noob at c#.net, but have been kicking around the beer house for a little while now. I have set up a web site using the beer house where members can register. The problem that I have is I written a book on the subject of my web site and
want to add a closed forum (layer?) that only people that have purchased my book can access. I am using vwd 2008 3.5 but can’t figure out the UI, BLL, DAL DATASTORE. Can anyone offer some advice as to how I can add another layer to the forum section of the
beer house. thanks in advance.
It's not a layer that you need. You should look at authentication for protecting a certain part of the site from unauthorised users. Have a look at Chapter 4 again.
I think maybe we are misunderstanding each other. I have built a site and do have a membership that you have to be registered for, in which I give some free lessons, but I want to add a side forum that is only accessible to the people that have bought my
book
So basically, you need to use Roles. These define what people are allowed to do. You already have two - anonymous users who can browse the unrestricted parts of the site, and basic members, who can access your free lessons. You need a third - paid members
who can access more valuable content.
Yes, you have the idea but, anonymous users can also read the registered forum, they just can post to it. What I would like to do (if this is possible) is for any user to click on the forum menu link and be able to see what
is available. If you are familiar The Beer House SDK, when you click on the menu link for the forum it opens the ShowForums.aspx page that shows a series of databound links. I would like for some of the links to redirect unauthorized users to a new page explaining
the restrictions. This way the more restricted members would also be able to read and post to the registered forum. Registered members could read and post, but could not access the more restricted pages and anonymous users could read some of the forum but
not access the more restricted pages.
Could I use the link on the show forums page to send the user to a blank page with a 301 redirect and from there to the explanation page or take the user to the more restricted content? I don’t know what all is available. Thanks again
I did it! I did it! I did it! I can’t believe it. I have been working on this longer than I want to think about. What a great way to start the New Year.
I read and reread and reread chapter 8 of The Beer House book. There I found in the showThread.aspx section “This page renders a paginable grid showing all posts of the thread, whose ID is passed on the querystring.”
So I viewed the ~\BrowseThreads.aspx in a browser and saw in the address bar the ForumID=7. I noticed the QueryString had a different ForumID for each section of the forum. So I went to the code behind for the BrowseThreads.aspx and converted the ForumID
to a variable with this line
I put it in the Page_Load event and tested the IsInRole with an if statement and upon failure I redirected to a new page. The whole code looks like this.
public partial class BrowseThreads : BasePage
{
protected void Page_Init(object sender, EventArgs e)
{
gvwThreads.PageSize = Globals.Settings.Forums.ThreadsPageSize;
}
if (forumID == "The Number In The QueryString" && !this.User.IsInRole ("The Role Your Using"))
{
Response.Redirect("To New Page.aspx");
} }
}
With this code you can create as many new restricted forums as you want. You will have to include the administrator and anyone else that should have access to this page by adding their name to the "role you are using" Happpy New Year!!!
jim alan
Member
8 Points
8 Posts
adding a second forum
Dec 27, 2010 09:17 AM|LINK
Hi all, I am still a noob at c#.net, but have been kicking around the beer house for a little while now. I have set up a web site using the beer house where members can register. The problem that I have is I written a book on the subject of my web site and want to add a closed forum (layer?) that only people that have purchased my book can access. I am using vwd 2008 3.5 but can’t figure out the UI, BLL, DAL DATASTORE. Can anyone offer some advice as to how I can add another layer to the forum section of the beer house. thanks in advance.
Starter Kit TheBeerHouse forum c# 3.5
Mikesdotnett...
All-Star
154955 Points
19872 Posts
Moderator
MVP
Re: adding layers to the forum
Dec 27, 2010 10:03 AM|LINK
It's not a layer that you need. You should look at authentication for protecting a certain part of the site from unauthorised users. Have a look at Chapter 4 again.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
jim alan
Member
8 Points
8 Posts
Re: adding layers to the forum
Dec 27, 2010 10:36 AM|LINK
I think maybe we are misunderstanding each other. I have built a site and do have a membership that you have to be registered for, in which I give some free lessons, but I want to add a side forum that is only accessible to the people that have bought my book
Mikesdotnett...
All-Star
154955 Points
19872 Posts
Moderator
MVP
Re: adding layers to the forum
Dec 27, 2010 11:35 AM|LINK
So basically, you need to use Roles. These define what people are allowed to do. You already have two - anonymous users who can browse the unrestricted parts of the site, and basic members, who can access your free lessons. You need a third - paid members who can access more valuable content.
http://weblogs.asp.net/scottgu/archive/2006/02/24/ASP.NET-2.0-Membership_2C00_-Roles_2C00_-Forms-Authentication_2C00_-and-Security-Resources-.aspx
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
jim alan
Member
8 Points
8 Posts
Re: adding layers to the forum
Dec 29, 2010 07:39 AM|LINK
Yes, you have the idea but, anonymous users can also read the registered forum, they just can post to it. What I would like to do (if this is possible) is for any user to click on the forum menu link and be able to see what is available. If you are familiar The Beer House SDK, when you click on the menu link for the forum it opens the ShowForums.aspx page that shows a series of databound links. I would like for some of the links to redirect unauthorized users to a new page explaining the restrictions. This way the more restricted members would also be able to read and post to the registered forum. Registered members could read and post, but could not access the more restricted pages and anonymous users could read some of the forum but not access the more restricted pages.
Could I use the link on the show forums page to send the user to a blank page with a 301 redirect and from there to the explanation page or take the user to the more restricted content? I don’t know what all is available. Thanks again
jim alan
Member
8 Points
8 Posts
Re: adding a second forum
Dec 30, 2010 04:56 PM|LINK
I did it! I did it! I did it! I can’t believe it. I have been working on this longer than I want to think about. What a great way to start the New Year.
I read and reread and reread chapter 8 of The Beer House book. There I found in the showThread.aspx section “This page renders a paginable grid showing all posts of the thread, whose ID is passed on the querystring.”
So I viewed the ~\BrowseThreads.aspx in a browser and saw in the address bar the ForumID=7. I noticed the QueryString had a different ForumID for each section of the forum. So I went to the code behind for the BrowseThreads.aspx and converted the ForumID to a variable with this line
I put it in the Page_Load event and tested the IsInRole with an if statement and upon failure I redirected to a new page. The whole code looks like this.
public partial class BrowseThreads : BasePage
{
protected void Page_Init(object sender, EventArgs e)
{
gvwThreads.PageSize = Globals.Settings.Forums.ThreadsPageSize;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string forumID = this.Request.QueryString["ForumID"];
if (forumID == "The Number In The QueryString" && !this.User.IsInRole ("The Role Your Using"))
{
Response.Redirect("To New Page.aspx");
}
}
}
With this code you can create as many new restricted forums as you want. You will have to include the administrator and anyone else that should have access to this page by adding their name to the "role you are using" Happpy New Year!!!
Starter Kit TheBeerHouse Authorication web development asp.net DAL
VeganMan
Member
82 Points
138 Posts
Re: adding a second forum
Jan 10, 2011 01:53 PM|LINK
Kewl... I will have to give it a try when I get that far in the book.
Thanks for sharing that Jim.