Re-specify the page of the FormSauthentication redirect to

xiaoxiao2021-03-06  82

In ASP.NET, by configuring it in Web.config:

You can access the REDIRECT to the Login.aspx page of any page to any page, in Login.aspx, can be redirected to the original page via the FormsAuthentication.RedirectFromLoginPage.

But sometimes you need to guide users to other pages.

Two methods:

The first is to use FormSauthentication.seTauthCookie, then write code redirect to other pages.

There is also a method, redirectFromLoginPage is actually redirecting the page based on ReturnURL = ... in the URL, we know that you can access this value via this.Request.QueryString ["ReturnURL"], but actually uses to throw an exception, discovery The reason is due to the querystring collection is read-only.

So we take the following measures:

PropertyInfo Info;

INFO = Request.queryString.gettype (). GetProperty ("isreadonly", bindingflags.nonpublic | bindingflags.instance;

IF (info! = null) info.setValue (this.Request.QueryString, False, NULL);

Request.QueryString ["ReturnURL"] = "Custom.aspx";

转载请注明原文地址:https://www.9cbs.com/read-108141.html

New Post(0)