Weird serious login/out post viewing issues 2.0

Dec 10, 2010 at 1:05 PM
Edited Dec 10, 2010 at 1:18 PM

Go to sahcinfo.org the posts are visible, If I login as a user my secure pages are available, but the posts are not visible, logout and the posts are visible again, login or out as admin and the posts are visible either way.  
Also login and try to access your profile and it asks for a login again. 

Give it a try with joesample as username and 6549a as password.

Coordinator
Dec 10, 2010 at 5:36 PM

I posted a comment in the Issue you created.

To summarize, in BE 2.0, the user needs to be assigned to a Role that has the "right" to "View Public Posts".

Dec 10, 2010 at 5:50 PM
Edited Dec 10, 2010 at 6:06 PM

All users are assigned to anonymous which allows public post viewing, as least they should be because I didn't choose admim or editors when setting up all the 400 users. do I have to assign a user to anonymous, I assumed that was the default?

So are they anonymous and can read posts until they login and then are they in a different role that cannot read public posts?

I need to have all users able to read public posts whether logged in or not.

Coordinator
Dec 10, 2010 at 6:14 PM

You cannot actually assign users to the Anonymous role.  Maybe you've done so directly in the SQL CE DB.  But in the control panel, if you go to a User's profile where you can manage roles, you'll notice there is no Anonymous role.

Anonymous is for people who are no logged into the blog.  They are anonymous because they are not logged in and we don't know who they are.  When a user is logged in, we know who they are, so they are no longer anonymous (speaking in general security terms).

For users, they should be assigned to a real role.  You can create additional roles ... it doesn't have to be just Administrators and Editors.  You could create a role called Users, for example.  And then assign the users to that role, and make sure the role has the right to "View Public Posts".  Feel free to test this out with joesample.

Dec 10, 2010 at 6:17 PM

So I will have to create a role and manually assign my 400 users to it one at a time, isn't there a way to automate it and assign all users to it?

Coordinator
Dec 10, 2010 at 6:19 PM

Unfortunately, there's not, but I'll create a quick script for you that will do it.........

Dec 10, 2010 at 6:21 PM
Edited Dec 10, 2010 at 6:35 PM

Thanks Ben, can you exclude the admin user so I won't screw things up?

I created a role called users that can view public posts.

Coordinator
Dec 10, 2010 at 6:35 PM

Paste the following into a new .ASPX page on your blog.  You can call it assign-role.aspx, for example.  It'll allow you to choose the Role you want to assign to all users.

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="BlogEngine.Core" %>
<%@ Import Namespace="System.Collections.Generic" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        if (!IsPostBack)
        {
            LoadRoles();
        }
    }

    protected void AssignUsersToRole(object sender, EventArgs e)
    {
        if (!Page.IsValid) { return; }

        List<string> usersToAddRoleTo = new List<string>();
        
        MembershipUserCollection col = Membership.GetAllUsers();
        foreach (MembershipUser user in col)
        {
            if (Roles.GetRolesForUser(user.UserName).FirstOrDefault(
                r => r.Equals(ddlRoles.SelectedValue,
                    StringComparison.OrdinalIgnoreCase)) == null)
            { 
                usersToAddRoleTo.Add(user.UserName);
            }
        }

        if (usersToAddRoleTo.Count == 0)
        {
            AppendMessage("All users are already in the role.");
            return;
        }

        try
        {
            Roles.AddUsersToRoles(usersToAddRoleTo.ToArray(),
                new string[] { ddlRoles.SelectedValue });
            
            AppendMessage(string.Format("Added role to {0} user(s)...",
                usersToAddRoleTo.Count));
            
            foreach(string username in usersToAddRoleTo)
            {
                AppendMessage(username);
            }
        }
        catch (Exception ex)
        {
            AppendMessage("Error: " + ex.Message); 
        }
    }

    private void AppendMessage(string message)
    {
        litResults.Text += "<br />" + message;
    }
    
    private void LoadRoles()
    {
        ddlRoles.AppendDataBoundItems = true;
        ddlRoles.DataSource = Roles.GetAllRoles().Where(
            r => !r.Equals("Administrators", StringComparison.OrdinalIgnoreCase));
        ddlRoles.DataBind();
    }
    
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList ID="ddlRoles" runat="server">
            <asp:ListItem Text="Select" Value="" Selected="True"></asp:ListItem>
        </asp:DropDownList>
        <asp:RequiredFieldValidator runat="server" ControlToValidate="ddlRoles"
            Text=" * Required" Display="Dynamic"></asp:RequiredFieldValidator>
        <br /><br />
        <asp:Button ID="btnAssignRoleToAllUsers" runat="server"
            Text="Assign Role to All Users" OnClick="AssignUsersToRole" />
        <br />
        <asp:Literal ID="litResults" runat="server" EnableViewState="false"></asp:Literal>
    </div>
    </form>
</body>
</html>

Dec 10, 2010 at 6:39 PM

Thanks Ben, a stand alone page or a new page though the control panel, hopefully it won'g affect the admin.

Coordinator
Dec 10, 2010 at 6:40 PM

It's a standalone page, intended for one-time use.... nothing fancy that integrates into the control panel.

Dec 10, 2010 at 6:45 PM
Edited Dec 10, 2010 at 6:59 PM

Get this error when trying to browse to the page.

Line 10: <script runat="server">
Line 11: 
Line 12:     protected override void OnLoad(EventArgs e)
Line 13:     {
Line 14:         base.OnLoad(e);
Coordinator
Dec 10, 2010 at 6:58 PM

Is there an error message too ?  Below it, for example?

Dec 10, 2010 at 7:00 PM

All this

c:\windows\system32\inetsrv> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /t:library /utf8output /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\assembly\dl3\47d9cd26\e7f55bd9_728fcb01\BlogEngine.Core.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\assembly\dl3\045cd57a\5e703c1c_2d96cb01\KMobile.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\assembly\dl3\a4ab4b2e\2efbf0d5_728fcb01\AjaxMin.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\assembly\dl3\8cbabb93\0ebec31a_2d96cb01\By360Impact.AutoEmail.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\App_global.asax.gfforxqu.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\assembly\dl3\86a80440\b6d72d17_2d96cb01\AjaxControlToolkit.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Management\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Management.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\assembly\dl3\013f4f83\4ee9e618_2d96cb01\Anthem.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\App_GlobalResources.-pqpxttq.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\assembly\dl3\6e5fc41b\8954b5e5_728fcb01\BlogML.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\assembly\dl3\a4c4a9ef\d05e71e9_728fcb01\System.Data.SqlServerCe.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Entity\v4.0_4.0.0.0__b77a5c561934e089\System.Web.Entity.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\App_Code.vpy_emiq.dll" /out:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\App_Web_iujki1z5.dll" /debug- /nowarn:41008 /define:_MYTYPE=\"Web\" /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System.Collections.Specialized,System.ComponentModel.DataAnnotations,System.Configuration,System.Linq,System.Text,System.Text.RegularExpressions,System.Web,System.Web.Caching,System.Web.DynamicData,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls,System.Xml.Linq /warnaserror- /optionInfer+  "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\App_Web_iujki1z5.0.vb" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\8e8e313e\e65ed328\App_Web_iujki1z5.1.vb"


Microsoft (R) Visual Basic Compiler version 10.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(12) : error BC30205: End of statement expected.

    protected override void OnLoad(EventArgs e)
                       ~~~~~~~~~~~~~~~~~~~~~~~~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(13) : error BC30035: Syntax error.

    {
    ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(14) : error BC30188: Declaration expected.

        base.OnLoad(e);
        ~~~~           
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(16) : error BC30689: Statement cannot appear outside of a method body/multiline lambda.

        if (!IsPostBack)
        ~~              
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(17) : error BC30035: Syntax error.

        {
        ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(18) : error BC30188: Declaration expected.

            LoadRoles();
            ~~~~~~~~~   
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(19) : error BC30035: Syntax error.

        }
        ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(20) : error BC30035: Syntax error.

    }
    ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(22) : error BC30205: End of statement expected.

    protected void AssignUsersToRole(object sender, EventArgs e)
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(23) : error BC30035: Syntax error.

    {
    ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(24) : error BC30689: Statement cannot appear outside of a method body/multiline lambda.

        if (!Page.IsValid) { return; }
        ~~                            
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(26) : error BC30188: Declaration expected.

        List<string> usersToAddRoleTo = new List<string>();
        ~~~~                                               
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(28) : error BC30188: Declaration expected.

        MembershipUserCollection col = Membership.GetAllUsers();
        ~~~~~~~~~~~~~~~~~~~~~~~~                                
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(29) : error BC30188: Declaration expected.

        foreach (MembershipUser user in col)
        ~~~~~~~                             
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(30) : error BC30035: Syntax error.

        {
        ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(31) : error BC30689: Statement cannot appear outside of a method body/multiline lambda.

            if (Roles.GetRolesForUser(user.UserName).FirstOrDefault(
            ~~                                                      
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(32) : error BC30188: Declaration expected.

                r => r.Equals(ddlRoles.SelectedValue,
                ~                                    
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(33) : error BC30188: Declaration expected.

                    StringComparison.OrdinalIgnoreCase)) == null)
                    ~~~~~~~~~~~~~~~~                             
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(34) : error BC30035: Syntax error.

            { 
            ~ 
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(35) : error BC30188: Declaration expected.

                usersToAddRoleTo.Add(user.UserName);
                ~~~~~~~~~~~~~~~~                    
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(36) : error BC30035: Syntax error.

            }
            ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(37) : error BC30035: Syntax error.

        }
        ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(39) : error BC30689: Statement cannot appear outside of a method body/multiline lambda.

        if (usersToAddRoleTo.Count == 0)
        ~~                              
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(40) : error BC30035: Syntax error.

        {
        ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(41) : error BC30188: Declaration expected.

            AppendMessage("All users are already in the role.");
            ~~~~~~~~~~~~~                                       
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(42) : error BC30689: Statement cannot appear outside of a method body/multiline lambda.

            return;
            ~~~~~~ 
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(43) : error BC30035: Syntax error.

        }
        ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(45) : error BC30689: Statement cannot appear outside of a method body/multiline lambda.

        try
        ~~~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(46) : error BC30035: Syntax error.

        {
        ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(47) : error BC30188: Declaration expected.

            Roles.AddUsersToRoles(usersToAddRoleTo.ToArray(),
            ~~~~~                                            
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(48) : error BC30035: Syntax error.

                new string[] { ddlRoles.SelectedValue });
                ~~~                                      
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(50) : error BC30188: Declaration expected.

            AppendMessage(string.Format("Added role to {0} user(s)...",
            ~~~~~~~~~~~~~                                              
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(51) : error BC30188: Declaration expected.

                usersToAddRoleTo.Count));
                ~~~~~~~~~~~~~~~~         
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(53) : error BC30188: Declaration expected.

            foreach(string username in usersToAddRoleTo)
            ~~~~~~~                                     
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(54) : error BC30035: Syntax error.

            {
            ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(55) : error BC30188: Declaration expected.

                AppendMessage(username);
                ~~~~~~~~~~~~~           
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(56) : error BC30035: Syntax error.

            }
            ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(57) : error BC30035: Syntax error.

        }
        ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(58) : error BC30689: Statement cannot appear outside of a method body/multiline lambda.

        catch (Exception ex)
        ~~~~~               
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(59) : error BC30035: Syntax error.

        {
        ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(60) : error BC30188: Declaration expected.

            AppendMessage("Error: " + ex.Message); 
            ~~~~~~~~~~~~~                          
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(61) : error BC30035: Syntax error.

        }
        ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(62) : error BC30035: Syntax error.

    }
    ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(64) : error BC30205: End of statement expected.

    private void AppendMessage(string message)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(65) : error BC30035: Syntax error.

    {
    ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(66) : error BC30188: Declaration expected.

        litResults.Text += "<br />" + message;
        ~~~~~~~~~~                            
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(67) : error BC30035: Syntax error.

    }
    ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(69) : error BC30205: End of statement expected.

    private void LoadRoles()
                 ~~~~~~~~~~~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(70) : error BC30035: Syntax error.

    {
    ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(71) : error BC30188: Declaration expected.

        ddlRoles.AppendDataBoundItems = true;
        ~~~~~~~~                             
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(72) : error BC30188: Declaration expected.

        ddlRoles.DataSource = Roles.GetAllRoles().Where(
        ~~~~~~~~                                        
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(73) : error BC30188: Declaration expected.

            r => !r.Equals("Administrators", StringComparison.OrdinalIgnoreCase));
            ~                                                                     
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(74) : error BC30188: Declaration expected.

        ddlRoles.DataBind();
        ~~~~~~~~            
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(75) : error BC30035: Syntax error.

    }
    ~
C:\HostingSpaces\sahcinfo\blogengine.sahcinfo.org\wwwroot\assign-role.aspx(92) : error BC30456: 'AssignUsersToRole' is not a member of 'ASP.assign_role_aspx'.

            AddHandler __ctrl.Click, AddressOf Me.AssignUsersToRole
                                               ~~~~~~~~~~~~~~~~~~~~

 

Coordinator
Dec 10, 2010 at 7:04 PM

It looks like the VB compiler is trying to process this code.  The first line of code I pasted in my last message is this:

<%@ Page Language="C#" %>
Is that the first line of code in your assign-role.aspx file?

Dec 10, 2010 at 7:11 PM

Got it working, so I choose Anonymous and click on assign role and then what role will it assign to Anonymous

Coordinator
Dec 10, 2010 at 7:13 PM

That's good ... Anonymous IS a role.  You want to assign a real role (not Anonymous) to all your users.  I think you said above that you created a role called "users".  If so, then you should choose "users" from the dropdown list and assign that role to all users.  And then make sure the role you chose (e.g. users) is assigned the right to "View Public Posts".

Dec 10, 2010 at 7:15 PM

OK I got it now, I was confused because I created a role called user, I have now assigned the user role to everyone, I ope not me the admin.

Thank you Ben.