'How to add additional param to forms auth

I am using forms auth in my app, and using the configuration below in my web.config file:

<authentication mode="Forms">
  <forms loginUrl="https://app.myapp.com/account/login" name=".MYAPP" timeout="60" />
</authentication>

This works fine. When users navigate to https://app.myapp.com, they are redirected to the login page, and then redirected back to the page they were trying to get to. However, I am expanding my app to utilize an arbitrary domain, such as "myname.myapp.com" or "departmentname.myapp.com". And for reasons beyond my control, I cannot change the domain of the login url. It always has to be https://app.myapp.com/account/login regardless of the arbitrary domain the request was initiated from. Can I add an additional param to the loginUrl that will provide visibility to the original request domain? returnUrl is already there, but it is relative, so it doesn't tell the login page which domain it originated from. I am looking for something like this:

When navigating to:

https://myname.myapp.com

Redirect to:

https://app.myapp.com/account/login?returnUrl=&domain=myname

Or, redirect to:

https://app.myapp.com/account/login?returnUrl=https://myname.myapp.com

Is that possible in the .Net framework?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source