Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to integrate Azure AD with my existing web form application which is not in mvc.
I want to Authenticate the users with Azure AD and based on that they will able to login into our existing application.

I have found lot's of examples for mvc application's but not for web form applications.

Please help

I have tried below code. but I am getting below response

error=invalid_request&error_description=AADSTS900144%3a+The+request+body+must+contain+the+following+parameter%3a+%27response_type%27.%0d%0aTrace+ID%3a+xxxxxxxx-xxxx-xxxx-xxxx-af348a6f4200%0d%0aCorrelation+ID%3a+f0a33d0c-xxxx-xxxx-xxxx-816e66bdea91%0d%0aTimestamp%3a+2021-08-26+09%3a49%3a18Z&error_uri=https%3a%2f%2flogin.microsoftonline.com%2ferror%3fcode%3d900144#

What I have tried:

var authority = "https://login.microsoftonline.com";
var tenant = "xxxxxxxx-xxxx-xxxx-xxxx-3914728445dc";
var authorizeSuffix = "oauth2";

var EndPointUrl = String.Format("{0}/{1}/{2}/authorize?resource=xxxxxxxx-xxxx-xxxx-xxxx-bd0030e86430", authority, tenant, authorizeSuffix);

var clientId = "xxxxxxxx-xxxx-xxxx-xxxx-bd0030e86430";
var redirectURL = "http://localhost:54321/SignIn.aspx";
var parameters = new Dictionary<string, string="">
{
{ "response_type", "code" },
{ "client_id", clientId },
{ "redirect_uri", redirectURL },
{ "prompt", "login"}
};

var list = new List<string>();

foreach (var parameter in parameters)
{
if (!string.IsNullOrEmpty(parameter.Value))
list.Add(string.Format("{0}={1}", parameter.Key, HttpUtility.UrlEncode(parameter.Value)));
}
var strParameters = string.Join("&", list);
var requestURL = String.Concat(EndPointUrl, strParameters);

Response.Redirect(requestURL);
Posted
Updated 10-May-22 2:48am
Comments
lmoelleb 27-Aug-21 6:38am    
I would create a simple .NET Core or .NET Framework MVC app following a tutorial. Once that is working, use the network tab of the browser to see where your requests goes wrong. It is hard to get this working without knowing 100% what needs to go on the wire.

1 solution

hello ..I am in same this same situation,I am also searching for integration with web forms application.
If u found the answer please help
 
Share this answer
 
Comments
Richard Deeming 12-May-22 11:41am    
"Me too" is not a solution to anyone's question.

If you want to ask for more information, click the "Have a Question or Comment?" button under the question and post a comment.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900