Home > Net >  Access NTLM authentication website ASP.NET HttpClient, wanted him to landing the pop-up box, ok?
Access NTLM authentication website ASP.NET HttpClient, wanted him to landing the pop-up box, ok?

Time:10-03

First of all, I have A web site A, set the domain authentication, the browser will automatically pop up when open the domain to validate input box, I in this website A put A page, if the domain account after landing, it will be according to the domain account, return A string of JSON content:
The
reference


Behind B I have another web site, the site default B can not log in, you can view the information, but if you want to edit, need to log in, I hope that after the landing point in the top right corner of the button, you can visit the web site A, pop-up domain validate input box, and enter, site B to get A page returns JSON, as the user information written to the Session,
I spelled:
 
Protected void btnLogin_Click (object sender, EventArgs e)
{
HttpClient client=new HttpClient ();
String json=client. GetAsync (" http://172.31.168.164:82/adlogin2.aspx "). The ToString ();
The UserInfo newuser=JsonConvert. DeserializeObject (json);
The Session. The Add (" username ", newuser. Username);
The Session. The Add (" employeeid ", newuser. Employeeid);
The userinfo. Visible=true;
//loginlink. Visible=false;
//the Session. The Add (" username ", "28021278");
}

But the return error is 401 Unauthorized.
Excuse me, how should to B landing process, the web site A login box pop up?

CodePudding user response:

Wrong, the error code returned above is: Unexpected character encountered while parsing the value: s. Path ', line 0, the position 0.

CodePudding user response:

Feeling is single sign-on,
You use redis store session as a vehicle for sharing session,

CodePudding user response:

I change at the front desk to implement with JS, put a iframe, when JS control iframe opened the website landing page B, B can pop-up website domain account verification box, enter account, website B returns JSON, display inside the iframe, the question becomes: how to JS to get into the iframe JSON? Use innerHTML return is: & lt; head> <body> , there is no other content,
 
The function getLogin () {
Window. Frames [' login ']. Location. The href="http:///adlogin2 B. Aspx";
Alert (window frames [' login '] document. ContentDocument. InnerHTML);
}

CodePudding user response:

If use webbrowser can obtain the document structure, like a normal browser operation