Use the HttpClient to hit the url.
An example would be the following:
static readonly HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync("application/logout.action");
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Bear in mind that you should create the full request. This means that you need to add the headers and cookies to the request.
Example of adding the authorization header (this is for client credentials flow, but you get the gist of it).
client.DefaultRequestHeaders.Authorization
= new AuthenticationHeaderValue("Bearer", "Your Oauth token");
Edit after comment
If the above does not work, it means that the logout page of application B does some actions on the client side.
- It could be removing the cookies, if information is stored there. This can't be achieved from the application 1 controller as the cookies are accessible per hostname for security reasons.
- It could be executing an XHR signoff http call. In this case you are in luck as you could identify it from your browser console and execute it from your own c# code
Worst case scenario, you can create a signoff action in the application B that you can call from c# and invalidate the session. When the user tries to access application B with an invalidated session, then return a 401 error and handle appropriatly.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…