Hi Friends,
I am developing a website project . It can sign-in successfully with Facebook/Windows Live ID/Yahoo/Google, but the value of System.Web.HttpContext.Current.User.Identity.IsAuthenticated always False after signed-in.
The sign-in process start with this code on my Default.cshtml:
<script src="https://XXXXXXX.accesscontrol.windows.net/v2/metadata/IdentityProviders.js?protocol=wsfederation&realm=http%3a%2f%2fwww.tipao.net%2f&reply_to=&context=&request_id=&version=1.0&callback=SignInPreparation" type="text/javascript"></script>
That script call this function:
<script language="javascript" type="text/javascript"> var identityProviders = []; // This function will be called back by the HRD metadata, and is responsible for displaying the sign-in page. function SignInPreparation(json) { identityProviders = json; } function windows_live_id_sign_in() { window.location.assign(identityProviders[2].LoginUrl); } function google_sign_in() { window.location.assign(identityProviders[0].LoginUrl); } function yahoo_sign_in() { window.location.assign(identityProviders[1].LoginUrl); } function facebook_sign_in() { window.location.assign(identityProviders[3].LoginUrl); } </script>
After users signed-in with Facebook/Google/Yahoo/Windows Live ID, it will be redirected to news.cshtml. On news.cshtml I try to capture the value of system.web.httpcontext.current.user.identity.isauthenticated , user's name, and email address.
This is the code on news.cshtml :
@{ var isAuthed = System.Web.HttpContext.Current.User.Identity.IsAuthenticated; var signed_in_status = ""; if (isAuthed) { signed_in_status = "signed in"; } else { signed_in_status = "not signed in"; } }
The problem is, it is always FALSE.
This is my web.config:
<?xml version="1.0" encoding="utf-8"?><configuration><system.web><compilation debug="true" targetFramework="4.5.1"><assemblies><add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /><add assembly="System.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /><add assembly="Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /></assemblies></compilation><httpRuntime targetFramework="4.5.1" /><customErrors mode="Off" /><pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" /></system.web><connectionStrings><add name="XXXXX" connectionString="Server=tcp:XXXXXX.database.windows.net,1433; Database=XXXXX; User ID=XXXX;Password=XXXXX; Connection Timeout=30;Encrypt=True" /></connectionStrings><runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" /><bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /></dependentAssembly><dependentAssembly><assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" /><bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" /></dependentAssembly><dependentAssembly><assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" /><bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" /></dependentAssembly><dependentAssembly><assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /><bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /></dependentAssembly></assemblyBinding></runtime><system.data><DbProviderFactories><remove invariant="System.Data.SqlServerCe.4.0" /><add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /></DbProviderFactories></system.data><appSettings><add key="StorageConnectionString" value="DefaultEndpointsProtocol=https; AccountName=XXXXXXXXX; AccountKey=XXXXXXX" /></appSettings></configuration>
I have tried to search on the internet for solutions, but I have not found ones. So, Where is the mistake exactly ? on my code or web.config ?
Please help me to solve this problem. Thank you very much.
Regards,
Joo Roby Widjaja.