Custom 404 pages cannot send messages due to relative path issues

My site currently implements custom 404 pages that we have mapped in IIS. Therefore, when a user does something like www.mysite.com/foo/bar/doesnotexist, he will execute the URL 404.aspx. This works fine, but when checking the returned HTML, the form 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 carefully look at the action URL, send it to 404.aspx, but this is a relative path, so it tries to execute if we postback www.mysite.com/foo/bar/doesnotexist/404.aspx. How to get my 404 completed pages for postback? (Www.mysite.com/404.aspx)

Thanks.

+3
source share
2 answers

Victor,

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

Since you are new to this, I hope a close Nazi will cut you short. Basically, when you write a question, there should be a list of similar questions that appear right under your question. If you see a question that looks like it can answer your question, follow the link and check it before submitting. 9 out of 10 times, your question may have already been answered.

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

+1
source

, axjx , , , -.

.

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

Source: https://habr.com/ru/post/1707703/


All Articles