Redirecting unauthentricated users to login or sign-up

Discussion in 'ASP.NET 2.0' started by manaloaa, Jun 6, 2005.

  1. Hello folks! Can anybody help with my problem?

    My website'sdefault/home pagecontainsthe main menu options (uses menucontrol object getting data fromSiteMapDataSource/web.sitemap). On the same page is the login object where users must login first before they can access other pages located in the "membersOnly" folder (this folder cannot be viewed by anonymous users).

    My web.sitemap configuration is:

    <siteMap>



    <siteMapNode title="Home" description="" url="~/default.aspx" >


    <siteMapNode title="Family Tree" description="" url="~/membersOnly/familyTree.aspx"> </siteMapNode>


    <siteMapNode title="Personal Info" description="" url="a.aspx"></siteMapNode>


    <siteMapNode title="Photo Album" description="" url="b.aspx"></siteMapNode>


    <siteMapNode title="Directory" description="Contacts Directory" url="c.aspx"></siteMapNode>


    </siteMapNode>


    </siteMap>

    My question is: How doI redirect unauthenticated users to display a separate page containing the sign-up form, and therefore eliminatetheerror message that says:


    Server Error in '/family' Application.


    The resource cannot be found.
    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /family/login.aspx





    Version Information:Microsoft .NET Framework Version:2.0.50215.44; ASP.NET Version:2.0.50215.44



    Please help me... Thanks in advance..!
    <!--
    [HttpException]: The file '/family/login.aspx' does not exist.
    at System.Web.UI.Util.CheckVirtualFileExists(String virtualPath)
    at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(String virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
    at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, String virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
    at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path)
    at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, String path, String pathTranslated, Boolean useAppConfig)
    at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    -->
     
  2. A cheap, quick,and dumb-a$$ .NET version 1.1 solution would be to Validate the User on the login page (your startup page)and, upon validation,create a global session variable like: Session("IsUserLoggedIn")=True


    Then on each page's code behind file, in the Page_Load section, on the first line, put something like


    If Session("IsUserLoggedIn") <> True
    Response.Redirect(Login.aspx)
    End if


    I think ASP.NET 2.0 has a much smoother way of doing this...based on your siteMapNode.I believe 'this' is the webcast that shows you how to do itusing siteMapNode.It's free and you just need a hotmail or msn account to sign in. Grab some popcorn. :)


    It's based from www.microsoft.com/webcasts


    try:
    http://www.microsoft.com/events/EventDetails.aspx?CMTYSvcSource=MSCOMMedia&amp;Params=%7eCMTYDataSvcParams%5e%7earg+Name%3d%22ID%22+Value%3d%221032275051%22%2f%5e%7earg+Name%3d%22ProviderID%22+Value%3d%22A6B43178-497C-4225-BA42-DF595171F04C%22%2f%5e%7earg+Name%3d%22lang%22+Value%3d%22en%22%2f%5e%7earg+Name%3d%22cr%22+Value%3d%22US%22%2f%5e%7esParams%5e%7e%2fsParams%5e%7e%2fCMTYDataSvcParams%5e


    or:
    http://www.microsoft.com/events/top10.mspx


    But the first bit of code will work fine if you just want to get going with 'something'.


    Cheers,
    RedRog [​IMG]










    Post Edited (RedDog) : 8/2/2005 9:37:18 PM GMT
     
  3. Thanks, RedDog! You are such an heaven-sent angel to me. I thought nobody would ever come to my rescue. It's been quite sometime ( i think 2 mos. already) that I've been entertaining the idea that this message board is nothing but purely a "message board" where "i get by a little help from my friends". Thanks to you, that changed a little bit. Good luck! And more power to you!
     

Share This Page