문제

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