Redirecting the user to the original action after logging in

The sequence of actions that I am trying to perform is given below.

Context: the user can add products to his account.

  • The user is trying to add a specific product. (He / she is not a login at this time.)
  • In the code behind, I need to redirect the user to the login page before I can add the product to the user account.
  • After entering the system, how to return the system back to the logic in order to complete the action in step 1.

Thank.

+3
source share
2 answers

, URL- .
URL- .

+2

, FormsAuthentication, , , : http://msdn.microsoft.com/en-us/library/xdt4thhy.aspx

, , (.. ), ASP.NET , -:

<authentication mode="Forms">
   <forms loginUrl="~/Public/Login.aspx" defaultUrl="~/Public/Default.aspx"/>
</authentication>

ReturnUrl , , : http://www.example.com/Public/Login.aspx ? ReturnUrl =% 2fprivate% 2forderproduct.aspx

, , , cookie , :

FormsAuthentication.SetAuthCookie(someUserIdentifier,isRememberMeSet);
FormsAuthentication.RedirectFromLoginPage(someUserIdentifier, isRememberMeSet);

, FormsAuthentication, URL. .

+2

Source: https://habr.com/ru/post/1787851/


All Articles