locked
Being redirected to old Login.aspx page RRS feed

  • Question

  • User1601006133 posted

    I have IIS7 with only one website, the default one. I used to have the Default.aspx and the Login.aspx page in wwwroot and they worked wonderful. I use .NET Framework 4.

    After a re-organization of my website, I deleted the Default and Login files and all the other forms. All I have left are images, xlsx and xml files with no impact on authentication/authorization.

    I created a folder in wwwroot named _public and in this folder I created the Home.aspx and Signin.aspx pages.

    I modified the web.config file, replacing defaultUrl from "Default.aspx" to "_public/Home.aspx" and the loginUrl from "Login.aspx" to "_public/Signin.aspx".

    I also added a defaultDocument:

    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="_public/Home.aspx" />
            </files>
        </defaultDocument>
       </system.webServer>

    The web.config file is in wwwroot.

    Now the problem is the following:

    - when I enter my IP, the Home.aspx page displays.

    - When I click Sign in I'm redirected to the Signin.aspx page where I authenticate

    - After authentication, instead of being redirected to the Home.aspx page, I have the following error:

    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: /Login.aspx
    
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.233

    On the Signin page I see the wrong query string on top: ip/_public/Signin.aspx?ReturnUrl=%2fLogin.aspx

    If I manually change to ip/_public/Signin.aspx?ReturnUrl=%2f_public%2fHome.aspx  it works, I'm authenticated and directed to the homepage.

    On Home.aspx I have this Sign in label with the text being <a href="_public/Signin.aspx">Sign in here</a> . Strangely, when I hover the mouse above in any client, the path I see at the bottom of the browser is ip/Login.aspx . When I click however I'm directed correctly to _public/Signin.aspx but with the wrong return query string as described above.

    I tried IIS reset, same problem.

    I looked in the IIS configuration, can't see any trace of Login.aspx there.

    I checked the web.config file in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config   .. the Login.aspx page is not mentioned there.

    I tried adding ~/ for for my paths in web.config and in the code, it makes no difference.

    I didn't change the name of my authentication cookie, it's .ASPXFORMSAUTH. There is a problem on the MSDN site (cannnot find the link now) but it applies when more than one applications are installed on the same server.

    Kindly help my IIS to forget about the old Login.aspx file in the root folder.

    Alex

    Wednesday, January 14, 2015 3:05 AM

Answers

  • User1601006133 posted

    I found a way: instead of using a label with a href in the Text property, I used an asp:HyperLink control with

    Text = "Sign in" and NavigateUrl = Page.ResolveUrl("~/_public/Signin.aspx")

    It redirects to the Signin page independent of the link used by the use to access the homepage: ip../_public/Home.aspx  or ip ony :)

    Cheers

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 14, 2015 12:41 PM

All replies

  • User1601006133 posted

    The problem was that somehow, when I copied the Home.aspx form from the development station to the server, I must have copied a wrong version because the a href was pointing to Login.aspx instead of the new Signin.aspx file...

    I cannot mark such a negligence as answer so I continue with a quick question on the use of a href.

    If the a href is "Signin.aspx", the redirect to the Signin page works well when the user accesses the homepage using    ip../_public/Home.aspx

    But when someone access it by ip only, the Signin href points to ip/Signin.aspx which doesn't exist.

    Now if I set the href to "~/_public/Signin.aspx" the redirect to Signin works well if the user enters the ip, but if it enters ip../_public/Home.aspx than it redirects to ip/_public/_public/Signin.aspx which doesn't exist.

    So the a href takes the ~ literally. Also it takes Server.MapPath literally (C:\inetpub...). What I need is a relative path to the Signin.aspx file

    And if I remove the defaultFile part from web.config, the users can't access my homepage at all: not authorized error...

    I have to find a way around this

    Wednesday, January 14, 2015 4:38 AM
  • User1601006133 posted

    I found a way: instead of using a label with a href in the Text property, I used an asp:HyperLink control with

    Text = "Sign in" and NavigateUrl = Page.ResolveUrl("~/_public/Signin.aspx")

    It redirects to the Signin page independent of the link used by the use to access the homepage: ip../_public/Home.aspx  or ip ony :)

    Cheers

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 14, 2015 12:41 PM
  • User-1151753377 posted

    Thank you for your sharing !Smile

    Thursday, January 15, 2015 3:12 AM