R – Custom 404 pages not being able to postback due to relative path issues


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)


Best Solution


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.