Allowing users to visit home page, but not browse the catalog.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 years ago
In our case, we'd like new (anonymous) users to be able to access the site home page instead of being directed to the login page immediately (not very friendly). But they should be prompted to register/log in when trying to drill down into the products. I don't see anything in the permissions/ACL/site settings to support this. Am I looking in the wrong places?

I'd also like them to visit all of the "pages" (About, Contact, etc) without logging in.
14 years ago
when you select 'allow navigation only for registered user, you can define the pages which will be available to non registered users with a little code manipulation

look at this post
https://www.nopcommerce.com/boards/topic.aspx?topicid=2660


this is an excerpt from my overrides
                    if ((!CommonHelper.GetThisPageURL(false).ToLower().Contains("/login.aspx"))
                        && (!CommonHelper.GetThisPageURL(false).ToLower().Contains("/register.aspx"))
                        && (!CommonHelper.GetThisPageURL(false).ToLower().Contains("/contactus.aspx"))
                        && (!CommonHelper.GetThisPageURL(false).ToLower().Contains("/aboutus.aspx"))
                        && (!CommonHelper.GetThisPageURL(false).ToLower().Contains("/captchaimage.aspx"))
                        && (!CommonHelper.GetThisPageURL(false).ToLower().Contains("/shippinginfo.aspx"))
                        && (!CommonHelper.GetThisPageURL(false).ToLower().Contains("/privacyinfo.aspx"))
                        && (!CommonHelper.GetThisPageURL(false).ToLower().Contains("/conditionsinfo.aspx"))
                        && (!CommonHelper.GetThisPageURL(false).ToLower().Contains("/passwordrecovery.aspx"))
                        && (!CommonHelper.GetThisPageURL(false).ToLower().Contains("/specialoffers.aspx"))
                        && (!CommonHelper.GetThisPageURL(false).ToLower().Contains("/products/596-order-a-sample.aspx"))
                        && (!CommonHelper.GetThisPageURL(false).ToLower().Contains("/default.aspx"))
                        && (!CommonHelper.GetThisPageURL(false).ToLower().Contains("/logout.aspx")))

EDIT
NOTE:
the process is different from v1.8 onwards - instead of altering BaseNopPage.cs, you edit the codebehind of the individual pages ( see post by ' efalsken ', below )
13 years ago
efalsken

Wondering if you found a solution for the home page --> login
I am dealing with the same issue.

I have tried changes on iis to default to index.aspx instead of default.aspx as well as changes in the BaseNopPage.cs.

The workaround I used for the other pages (i.e. about us) was:
Creating a new page

<%@ Page Language="C#" MasterPageFile="~/MasterPages/TwoColumn.master" AutoEventWireup="true" CodeFile="about.aspx.cs" Inherits="about" %>
<%@ Register TagPrefix="nopCommerce" TagName="Topic" Src="~/Modules/Topic.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cph1" Runat="Server">
<nopCommerce:Topic ID="topicAboutUs" runat="server" TopicName="AboutUs">
    </nopCommerce:Topic>
</asp:Content>

INSTEAD OF
<%@ Page Language="C#" MasterPageFile="~/MasterPages/OneColumn.master" AutoEventWireup="true"
    Inherits="NopSolutions.NopCommerce.Web.AboutUsPage" Codebehind="AboutUs.aspx.cs" %>

<%@ Register TagPrefix="nopCommerce" TagName="Topic" Src="~/Modules/Topic.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cph1" runat="Server">
    <nopCommerce:Topic ID="topicAboutUs" runat="server" TopicName="AboutUs">
    </nopCommerce:Topic>
</asp:Content>
13 years ago
Yes, and there is a better way. In the Default.aspx.cs file (the codebehind) simply add or change this property:

    protected override bool allowAnonymous {
      get { return true; } // false to prevent anonymous users from seeing this page
    }
13 years ago
OOps.  On BaseNopPage.cs  ~line 120

                    if (!this.AllowGuestNavigation)
                    {
                        //it's not login/logout/passwordrecovery/captchaimage/register/accountactivation page (be default)
                        string loginURL = SEOHelper.GetLoginPageUrl(false);
                        //Response.Redirect(loginURL);
                        Response.Redirect("index.aspx");
                    }

That was the other workaround to go to index.aspx.  I had not commented out the line above it.
13 years ago
Right. That will work too, but with my solution, you don't have to modify the base page and add the page-name check for all the different pages you might want to expose. By putting the code on each page, you properly delegate the responsibility to the page itself to say if it should be allowed or not. In addition, each page you might add to that "If" check is an additional string comparison, so not as performant.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.