I am developing a very basic application in C# and Asp.Net using New Website-->Asp.Net web site.This is a simple login control application available in Visual Studio.
After starting a project, I found folder structure like that
Project name "WebSite2" under which I have folders like "Account", "Scripts" and "Styles" and few files like "About.aspx", "Default.aspx" and "Web.config" under the same "WebSite2" folder. Under "Account" folder I have files like "ChangePassword.aspx","ChangePasswordSuccess.aspx","Login.aspx","Register.aspx" and "Web.config". Now I have add a simple page "ThankYou.aspx" under "Account" folder and "Thanks" under "WebSite2" folder. I have modified "Register.aspx.cs" file so that whenever a new user will register, an email will be sent to the persons inbox and from where he will activate his account and this functionality is working fine.

Now the problem is that whenever a new user registered, an email will be send to him and simultaneously he will be landed to "ThankYou.aspx" page, but here the user is redirecting to "Login.aspx" page.
This URL appears http://localhost:4201/WebSite2/Account/Login.aspx?ReturnUrl=%2fWebSite2%2fAccount%2fThankYou.aspx
I have tried it with so many combinations but always getting "Login.aspx" page. I have tried generating the path like Response.Redirect("~/Account/ThankYou.aspx"); and Response.Redirect("~/ThankYou.aspx");I have tried it with other combinations also but instead of redirecting to "ThankYou.aspx" page, it is redirecting to "Login.aspx" page.
But whe I use Response.Redirect("~/Thanks.aspx"); it is working fine.
Can you please help me in that?
Thanks in advance.

Hi can you post your code?

On your page load are you using the page postback on the onload event?

If not then the page will execute the load instructions as the order the page renders in during a post back is 1. Reload page 2. process postback routine.

e.g for VB.net:

Protected Sub Page_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 'Page always loads after postback so filter out code here 
 if not ISPostBack then
    'code to load in page that you only want in  page loading
 end if

end sub

Sub MyRegistrationThingy (ByVal sender As Object, ByVal e As System.EventArgs) Handles Whatever.Click()
  ' code you want to run
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.