FormsAuthentication.RedirectFromLoginPage reload p

2019-08-17 09:15发布

问题:

I am using the .Net memebership system, and uptil now I haven't had any real troubles with it. I now have a overlay where a user can create a profile. When the profile is created I just want to redirect to the same page, and not to the default page or the return url - which doesn't exists.

I have tried to stop the FormsAuthentication.RedirectFromLoginPage response, but with no effect:

 FormsAuthentication.RedirectFromLoginPage(username, false);
 // End the redirect so it doesnt redirect to default url (front-page)
 Response.End();
 Response.Redirect(Request.RawUrl);

Does anyone have an idea to how this can be solved?

回答1:

Use this instead:

FormsAuthentication.SetAuthCookie(username, false);
Response.Redirect(Request.RawUrl);