Click here to Skip to main content
15,168,971 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


What I have tried:

var authority = "";
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);

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.

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