views:

143

answers:

2

My site currently implements custom 404 pages which we have mapped in IIS. So when a user does something like www.mysite.com/foo/bar/doesnotexist, it will execute the 404.aspx URL. This works great, but when inspecting the HTML returned, the form post URL is relative:

<form method="post" action="404.aspx?404%3bhttps%3a%2f%2ftestserver%3a443%2ffoo%2fbar%2fdoesnotexist" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">

If you look closely the action URL is posting to the 404.aspx but it's a relative path, so it is trying to execute if we do a postback www.mysite.com/foo/bar/doesnotexist/404.aspx. How do I get my executed 404 pages to postback properly? (www.mysite.com/404.aspx)

Thanks.

+1  A: 

Victor,

Your question is a duplicate so I think you will probably find your answer here.

Since you are new here hopefully the close Nazi's will cut you some slack. Basically when you write a question there should be a list of similar questions that pop-up right under your question. If you see a question that looks like it may answer your own, follow the link and check it out before you post. 9 out of 10 times your question may have already been answered.

Good luck in finding your answer, I think there should be a lot of good information on that link.

matt_dev
A: 

This can also happen if you are using axjx and pulling one page into another and the pages are in diffrent directories, easy way round it is rewrite the forms action object on page load from the root of your web site.

e.g.

        //Rewirte forms post action. 
        form1.Action = "/{dir}/{currentpage}.aspx?" + Request.QueryString;
TheAlbear