How to make pages private ? Just for the users ?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 14 ans
I would like to create few pages, that can be accessed only by the registered users ? and i don't want those pages to be public to everything, only registered users who have login username/password

Please guide me in a right direction ?
Il y a 14 ans
any kind of help would be appreciated ....
Il y a 14 ans
Create a sub folder like yourstie.com/members - You will then need to add a web.config to the sub folder and add which members or roles have access to this folder.  Have a look at this article.  http://www.theserverside.net/tt/articles/showarticle.tss?id=FormAuthentication

hope this helps,
Matthew
Il y a 14 ans
Skiltz wrote:
Create a sub folder like yourstie.com/members - You will then need to add a web.config to the sub folder and add which members or roles have access to this folder.  Have a look at this article.  http://www.theserverside.net/tt/articles/showarticle.tss?id=FormAuthentication

hope this helps,
Matthew


Thanks for replying back mathew, yea i already know about the method, i was just trying to find if there is something in-built in nopCommerce 1.4 as my website is live so don't wanna touch webconfig.

Even if the website is live can i do it and i just have to re-build the website ? what dll files i have to replace then ? and what else ?

I WANT TO MAKE A PAGE PRIVATE, do you know any other alternative way or trick instead of doing any modification in the code ?

Thanks once again for replying back
Il y a 14 ans
An existing page or a new page?  The chnages I descibe above will not effect anything existing of the site.  Your are not editing the web.config in the root directory but creating a new one in the sub folder.  I don't beleive there is anything exisitng feature in nop to make a page private.
Il y a 14 ans
Skiltz wrote:
An existing page or a new page?  The chnages I descibe above will not effect anything existing of the site.  Your are not editing the web.config in the root directory but creating a new one in the sub folder.  I don't beleive there is anything exisitng feature in nop to make a page private.


So mathew, if i add folder as member, add an aspx page in it and add w) i don't have to rebuild the project ? and it won't mess up the whole project ? Just want to make sure as don't want to take any chance
Il y a 14 ans
If you don't want to take any chance then don't do it (you need to confident in your own abilities).  Test locally and if it works locally then deploy.  If your .aspx has no code behind that doesn't need to be compiled then it should work fine.
Il y a 14 ans
ok mathew, i was trying locally, created folder as "Members" and within this folder created an aspx page and webconfig file

Here is the code of my tech.aspx page (i deleted .cs file because when we add new item it automatically creates .cs so i deleted so that i don't have to re-build the project)

<%@ Page Language="C#" MasterPageFile="~/MasterPages/TwoColumn.master" %>


<asp:Content ID="Content1" ContentPlaceHolderID="cph1" runat="Server">
    <div>
    
    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="http://www.google.com">THIS IS PRIVATE AREA ONLY FOR TECHNICIANS</asp:HyperLink>
    </div>
</asp:Content>

Here is the my webconfig
<?xml version="1.0"?>
<configuration>
    <appSettings/>
    <connectionStrings/>
    <system.web>
      <authorization>
        <allow roles="Admin"/>
        <allow roles="Tech"/>
        <deny users="?"/>
      </authorization>
    </system.web>
</configuration>
-------------------------------
from my admin section i went to : admin section > manage customers > magane roles
created a role as "Tech"

then i created an account/username and i linked that specific username with that role "tech" by checking that checkbox of Tech role within the username details

so now only this username is defined as tech role right ? or only this username/user account should be able to access the page but in my situation if i login with other member username who is not defined as Tech role still i can access the tech.aspx page

in my webconfig, i tried this too : <deny users="*"/> in this situation only admin can access the page not even the username that i linked with tech role can access, by using "*" sign only admin gets access.

Please guide me
Il y a 14 ans
Anyone ? Please help !!!!!
Il y a 14 ans
paste this code into the page_load event of the page you want to restrict.


if (NopContext.Current.User == null || NopContext.Current.User.IsGuest)
            {
                // chose one of these options

               // 1 - either redirect to login url  
                string loginURL = SEOHelper.GetLoginPageURL(true);
               Response.Redirect(loginURL);
               // 2 - or anotherpage
               Response.Redirect("~/restrictedArea.html");
              // 3 - anything you want
              
            }


look at Account.aspx.cs as example.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.