locked
response.redirect giving a 404 error when resource exists RRS feed

  • Question

  • User-1767698477 posted

    This is frustrating. I have checked my paths carefully. At the moment, I'm just trying to get this to work on my local machine.

    Protected Sub SecondButtonCommand(sender As Object, e As CommandEventArgs)
    Session("SSN") = e.CommandArgument.ToString
    'Response.Redirect("~/app/Mortgage_applicaton_1.aspx", True)
    Response.Redirect("./app/Mortgage_applicaton_1.aspx", True)
    End Sub

    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: /mortgageapply/users/app/Mortgage_applicaton_1.aspx

    This request is coming from a logged in page. I can take the url in my browser, http://localhost:54848/mortgageapply/users/app/Mortgage_applicaton_1.aspx remove the Mortgage_applicaton_1.aspx and hit my enter key and I'm taken to a page showing a directory of the all the files in the directory. I can click on any of the pages and the page will load into browser.

    What is the problem here with response.redirect ?

    Friday, April 3, 2020 2:43 AM

Answers

  • User475983607 posted

    You have to understand that the community cannot see your source files.  A 404 is is clear; the URL/Web Form does not exist.  Maybe because application is misspelled?

    http://www.mortgageloanapply.com/users/app/Mortgage_applicaton_1.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 4, 2020 11:41 AM

All replies

  • User-1330468790 posted

    Hi sking,

     

    I can see that you used a relative url for the redirect method. 

    Reason of the problem:

    You passed a wrong relative url for the target page.

    The whole url for the target page is below url

    http://localhost:54848/mortgageapply/users/app/Mortgage_applicaton_1.aspx 

    but what you passed in the redirect method is below relative urls which represents two mismatching urls respectively.

    ~/app/Mortgage_applicaton_1.aspx => http://localhost:54848/app/Mortgage_applicaton_1.aspx 
    
    OR:
    
    ./app/Mortgage_applicaton_1.aspx => http://localhost:54848/...same folder of the current page.../app/Mortgage_applicaton_1.aspx  

     

    Solution:

    Replace the above wrong urls with below relative url:

    ~/mortgageapply/users/app/Mortgage_applicaton_1.aspx 

    Note that in asp.net, the tilde notation (~)  means the server-side application root and the dot notation (.) means the current path level.

     

    Hope this can help you.

    Best regards,

    Sean

    Friday, April 3, 2020 6:03 AM
  • User-1767698477 posted

    Thank you for your response Sean, however it is not the solution to the problem. I have to contact my hosting provider to find out why this is not working. I added hyperlink4 at the bottom of this code. The link works fine with the NavigateUrl="./app/Mortgage_application_1.aspx" . The page is /users/default.aspx and the user is logged into this page.

    The button next to Hyperlink4 with the Secondbuttoncommand should also work. But it doesn't. I tried it with a full url on my live site and I am firstly logged out, and secondly after logging back in taken to this page:

    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: /users/app/Mortgage_applicaton_1.aspx

    Protected Sub SecondButtonCommand(sender As Object, e As CommandEventArgs)
    Session("SSN") = e.CommandArgument.ToString
    Response.Redirect("http://www.mortgageloanapply.com/users/app/Mortgage_applicaton_1.aspx", True)
    ' Response.Redirect("./app/Mortgage_applicaton_1.aspx", True)
    ' Response.AddHeader("REFRESH", "4;URL=./app/Mortgage_applicaton_1.aspx")
    End Sub


    <asp:TemplateField ShowHeader="False" HeaderText="">
    <ItemTemplate>
    <asp:Button runat="server" Text="Edit App" ID="EditApp" oncommand="Secondbuttoncommand" CommandName="Editapp"
    CommandArgument='<%#Bind("borssn") %>'></asp:Button>
    </ItemTemplate>
    </asp:TemplateField>


    <asp:TemplateField HeaderText="3.2 File">
    <ItemTemplate>
    <asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl="./app/Mortgage_application_1.aspx" Enabled="true">link</asp:HyperLink>
    </ItemTemplate>
    </asp:TemplateField>

    Saturday, April 4, 2020 5:52 AM
  • User475983607 posted

    You have to understand that the community cannot see your source files.  A 404 is is clear; the URL/Web Form does not exist.  Maybe because application is misspelled?

    http://www.mortgageloanapply.com/users/app/Mortgage_applicaton_1.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 4, 2020 11:41 AM
  • User-1767698477 posted

    Yes! That's right...Thanks for your eyes and spotting that mistake! It is working now fine. Either one of these works now:

    Response.Redirect("./app/Mortgage_application_1.aspx", True)
    'Response.Redirect("~/users/app/Mortgage_application_1.aspx", True)

    Saturday, April 4, 2020 6:13 PM