Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Step 1 # Login Page Load after that I Press a Button which hit a method in login Controller name is loginProcess

Step 2# when login Process hit it's call a method SignIn

Step 3# SignIn method it's call Azure Authentication








C#
Login Controller 
View Bind with Login 

[HttpGet]
        public  ActionResult Login()
        {
            var DashboardDate = DateTime.Now.ToShortDateString();
            ViewBag.Date = DashboardDate;         
            return View();
        }


HTML
@using (Html.BeginForm("LoginProcess", "Login", FormMethod.Get, new { @class = "" }))
{
    
 <input class="AppBtnSimpleStyle btn btn-primary btn-lg" type="submit" value="Login" />
                    
}


<pre lang="c#">

  [HttpGet]
        public async Task <ActionResult>LoginProcess()
        {
            try
            {
              if (await new ServiceAPIConnection().SignIn())
                {




  }
            catch (Exception ex)
            {
                //new ExceptionHandling().InsertErrorLog(ex);
                GlobalMembers.DynamicDialog("Your credentials did not work or the service is down. Please try again." + "|Login: 03");

                return RedirectToAction("Login", "Login");

            }

            //progressbar.Visibility = Visibility.Collapsed;

        }


C#
public async Task<bool> SignIn()
       {
           try
           {
               SignOut();
                AuthenticationResult result = await authContext.AcquireTokenAsync(GlobalSettings.todoListResourceId, GlobalSettings.clientId, redirectURI, new PlatformParameters(PromptBehavior.Always));
               if (string.IsNullOrWhiteSpace(result.AccessToken))
               {
                   return false;
               }

               userName = result.UserInfo.DisplayableId.ToString().Trim();
               userToken = result.AccessToken.Trim();

           }
           catch (Exception ex)
           {
               return false;
           }


           return true;

       }


What I have tried:

Problem: When I run the Project On Localhost Office365 Login screen working. When I upload project on Azure login screen not show. I got this Error


Error HRESULT E_FAIL has been returned from a call to a COM component.
Posted

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