Getting Page can't be displayed error after Response.Redirect on submit button click

2.1k views Asked by At

I am getting a weird error on my asp.net web form page. I have a legacy page built up with full functionality. It has got several data controls on the page. After performing required operations when I click on submit button, internet explorer goes blank. It says page can't be displayed.

My code is old enough, so it actually works on few production sites. But recently I have deployed on a new production site. If I browse the same page using internal URL and perform same operation, it does not show any error message and everything works smoothly.

To give a background for the issue, when I click on submit button it calls web service on backend and comes back with web services result. Once it gets results back, it uses response.redirect() to same page (by creating url - Request.Url.AbsolutePath)with some additional parameters in querystring. If I refresh page then it shows same page correctly.

Page in IE - enter image description here Page in chrome - enter image description here

2

There are 2 answers

0
Manoj Attal On BEST ANSWER

Issue was not in code, but as I expected in production setup configuration. In production configuration a public URL something like www.test.com was redirected to www.test.com:7500. So when user was request website URL, it was being redirected to 7500 port on which application was hosted. It worked great until, response.redirect performed in asp.net code. When response.redirect performed in ASP.NET, in Request.Url.AbsolutePath server got URL as www.test.com:7500. So it tried to redirect it to 7500. But this redirection was set at public URL. When internally it tried to do the same it was not working.

I went with quick fix approach to fix this issue. I removed request redirection on public URL and set my site on port 80. This fixed my issue.

1
TheAlbear On

With out seeing the code it could be a number of things.

But as a guess I think that there maybe some url rewriting going on and then when the page posts back to its self it is not posting back to the rewritten page but to the underlining page.

You can try setting the form action to the rewritten page in the code behind.

form.action = "myrewrittenurl.com/path";

You can also try setting the form action to

<form action='#'

Which can work with some rewriters.