简体   繁体   中英

ASP.NET Authentication Questions

I use ASP.NET and ASP.NET Authentication.

I have a website with structure like:

ROOT
   - CMS
     - AdminCms
     - web.conf*
   - FORUM
     - AdminForum
      - web.conf*
   - web.conf ***

Now in web.conf *** I use for CMS LOGIN PAGE

<authentication mode="Forms">
  <forms loginUrl="~/Cms/AdminCms/Login.aspx" timeout="2880" />
</authentication>

My Questions:

  • How can I have another DEFAULT LOGIN PAGE for another folder? (if the user use for example FORUM).
  • Would be possible insert in web.conf* another

<authentication mode="Forms">
  <forms loginUrl="~/Forum/AdminForum/Login.aspx" timeout="2880" />
</authentication>

Any ideas?

Based on my comment earlier - Forms authentication allows redirecting a user to different pages after a successful login. To enable this, the forms authentication keeps track of the original page a user came from in the ReturnUL request parameter to the login page.

In your case you could do something like this in the codebehind of your login page after a successful login:

string originalTarget = Request.Params["ReturnUrl"];

if(originalTarget  != null)
{
   if(originalTarget.Contains(@"/FORUM/")
      Response.Redirect(someForumURL);
   else
      Response.Redirect(someCMSURL);
}

Edit: Here also a link to an article - Forms Authentication - Redirecting users to a Page other than Default.aspx

如果您将文件夹,CMD和论坛标记为IIS中的应用程序,则可以轻松执行此操作,因为它们都将是一个单独的应用程序域。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM