Ich habe eine login.aspx. In dem gibt es einen Code zum Umleiten der Seite.formsauthentication redirecttologinpage funktioniert nicht
Server.Transfer(string.Format("~/admin/FillUserExtraInfo.aspx?UserName={0}",Server.UrlEncode(loginInitial.UserName)));
Es hat funktioniert, dann in FillUserExtraInfo.aspx
protected void Page_Load(object sender, EventArgs e)
{
// retrieve the username from the querystring
userName = this.Request.QueryString["UserName"];
string mode = UsefulFunctions.GetOperatingMode();
if (mode == ConfigurationSettingValues.OperatingModes.Backup.ToString())
FormsAuthentication.RedirectToLoginPage();
jedoch FormsAuthentication.RedirectToLoginPage() funktioniert nicht. Das Programm läuft weiter bis zum Ende von Page_Load und geht dann zurück zur Anmeldung.
AKTUALISIERT: Während der Zeit fand ich die URL bacomes http://localhost:53906/Login.aspx?ReturnUrl=%2fLogin.aspx%3fAction%3dLogout
schließlich. aber ich habe einen Fehler:
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
Meine web.config:
<authentication mode="Forms">
<forms loginUrl="Login.aspx" protection="All" timeout="30" requireSSL="false" slidingExpiration="true" defaultUrl="default.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false"/>
</authentication>
Meine Fragen:
- Warum FormsAuthentication.RedirectToLoginPage() funktioniert nicht?
- Wie gehe ich mit dem Fehler um?
Vielen Dank.
Zweite Aktualisierung: Ich habe Response.End() nach FormsAuthentication.RedirectToLoginPage() dann funktioniert, aber die Ausnahme ist immer noch da.
Aber ich brauche die Variable "Username" und zu übergeben. –
Ich habe meine Antwort bearbeitet. bitte nachprüfen, ob ich es noch nicht getestet habe. –
Nicht sicher warum. Die Seite kann nicht umgeleitet werden. Es funktioniert nicht. –