I'm trying to display response.write function after user completes registration form.

I've done it like this, but it doesn't work. I already tried both ways, still nothing has changed.

Response.Redirect("Login");
Response.Write("Registration successful!");

By it "doesn't work" i mean the "registration successful" never shows up.

I will appreciate any help. Thank you!

有帮助吗?

解决方案

Since you Redirect then any Write after that will simply not happen.
With Redirect execution is redirected to another page.

To display the message and then redirect you could add a HTML header in the response. Something like this will show the message, delay 3 seconds and then redirect.:

Response.Write("Registration successfull!");
Response.AddHeader("REFRESH","3;URL=Login");

其他提示

Sani is correct. ASP.NET will redirect the server to render the Login page. To add to his answer, if you want to display a message on the Login page after successful registration, you'll need to pass "Registration Successful" in some way. One technique is to add it to the query string so instead of Response.Redirect("Login") you might say

Response.Redirect("Login?message=Registration Successful")

Your LoginController's Index method can accept a string parameter called message which could then be passed to the the Login view through the model or perhaps through ViewData.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top