Issue with tilde (~) parsing in <asp:Login>

.net , asp.net Palwal, India
  • 12 years ago

    I'll say from the outset that I am a complete ASP.Net Newbie.

    I have had a project management system developed for me in ASP.Net and C#, and I am trying to learn from/play with the code. Users are directed to a login page when they first enter the system, which is in the /login subfolder. After a user enters their username and password and presses the "Login" button, instead of going to /default.aspx, I am given a 404 error stating it can't find "/login/~/default.aspx".

    The error seems to be related to the following code:

    <asp:Login ID="cntrLogin" runat="server" PasswordRecoveryText="Forgot Password?"
                                PasswordRecoveryUrl="~/login/ForgotPass.aspx" CssClass="LoginSpace" Height="30px" OnAuthenticate="cntrLogin_Authenticate" TitleText=" " UserNameLabelText="User Name: " Width="348px">
                                <FailureTextStyle CssClass="LoginError" />
                                <TitleTextStyle CssClass="LoginTitle" />
                                <InstructionTextStyle CssClass="LoginLabel" />
                                <TextBoxStyle CssClass="LoginData" />
                                <LoginButtonStyle CssClass="LoginBtn" />
                                <ValidatorTextStyle CssClass="LoginError" />
                                <LabelStyle CssClass="LoginLabel" />
                                <HyperLinkStyle CssClass="LoginLink" />
                                <CheckBoxStyle CssClass="LoginCheckbox" />
                            </asp:Login>

    If I click on the "Forgot Password" URL it sends me to the correct page, so it doesn't seem to be an overall ASP.Net problem with parsing tildes - but I could be wrong?

    The relevant code in login.master:

     <form id="frmi" action="~/default.aspx" runat="server" style="margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;">
        <Part:Header ID="Part_head" runat="server" IncludePath="../" />

    The resulting HTML source becomes: <form name="aspnetForm" method="post" action="~/default.aspx" onsubmit="BLOCKED SCRIPTreturn WebForm_OnSubmit();" id="aspnetForm" style="margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;">

    I have href="/~design/style.css"  just three lines above and it correctly results in href="../design/newstyle.css". It is a bizarre problem

    The system works as expected on our webserver which runs SBS2003 and IIS6 and MSSQL 2005. I am running VS2008 Express SP1, MSSQL 2008 Express Edition and .Net 3.5 SP1 on Vista Ultimate SP1 with all updates installed and the same issue occurs whether I run it via VS2008 Development Server or IIS7.

    Your help is greatly appreciated because I have spent nearly a week searching trying to find a solution.

  • 12 years ago

    If your default page is at root then u should use "~/default.aspx"  not "/login/~/default.aspx"

  • 12 years ago
    the code IS "~/default.aspx" - it results in "/login/~/default.aspx" for some reason?

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Anyone who considers arithmetic methods of producing random digits is, of course, in a state of sin.” - John von Neumann