Secret
Secret

Reputation: 2647

ASP.NET Response.Redirect() doesn't work without try/catch

I have a trouble, which I didn't get earlier with the ASP.NET. I can't redirect to the some location with the method Response.Redirect()

I've read another topics and may tell you, what exactly I have tried:

I shall paste ONLY one of the variants, because as I wrote upper I tried different ways, but no success.

Code: http://ideone.com/Y8Fwpt

Redirect on 58th line doesn't work even there is a handler for the ThreadAbortException. Calling JS-scenario on 62nd line - ignores too.

Even if I remove try/catch block - nothing will change.

Please, help me to fix this issue!

Upvotes: 1

Views: 1272

Answers (1)

Tieson T.
Tieson T.

Reputation: 21239

I could make the redirect work if I removed the onclick() you have on the login form - I think your query string isn't coming across correctly, so you wind up just doing a quick page refresh. So, I would make two suggestions:

One, remove all the script & Ajax stuff you're trying to do, and get it working with normal postbacks first - then you can go back and try the async stuff.

Two, I wouldn't mess with creating your own cookies at this point - the MySQLConnector library has Membership and Role providers you can use that are built to connect to MySQL databases.

In a nutshell, the idiom I hold near and dear when I'm developing is "do the simplest thing that works," which in this case is just "classic" ASP.NET postbacks...

HTH.

Upvotes: 1

Related Questions