Cross Domain Login at ASP.NET

I have an ASP.NET site with a login page that redirects to the default page if authentication succeeds. I have another ASP.NET site in another domain where I need to place a login form that will redirect an already authenticated user to the default page on the first website. What is the best way to do this?

Any help would be appreciated.

+5
source share
2 answers

Thank you for your responses. I think my question was not precise enough.

I solved my problem using an iframe with the first login page as the source.

<iframe id = "iframe1" name ="loginFrame" src="http://domain2/Login.aspx?for_web=true" onload="iframeLoaded" ></iframe> 

To redirect to the default start page on the first site, added OnClientClick = "formWeb.target = '_ parent';" on the login button. Therefore, when the "Login" button is pressed, in case of successful authentication, the default page (in another domain) will be opened in the same window (and not in the frame).

 <form id="formWeb" runat="server"> <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" OnClientClick="formWeb.target ='_parent';" /> </form> 
0
source

What you need is one input. The succession login redirection mechanism is located in the web.config file

see here http://msdn.microsoft.com/en-us/library/eb0zx8fc.aspx

 <configuration> <system.web> <authentication mode="Forms" > <!-- The name, protection, and path attributes must match exactly in each Web.config file. --> <forms loginUrl="login.aspx" name=".ASPXFORMSAUTH" protection="All" path="/" domain="contoso.com" timeout="30" /> </authentication> <!-- Validation and decryption keys must exactly match and cannot be set to "AutoGenerate". The validation and decryption algorithms must also be the same. --> <machineKey validationKey="[your key here]" decryptionKey="[your key here]" validation="SHA1" /> 

Also see here: ASP.NET Form Authentication and Multiple Domains

+1
source

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


All Articles