User.Identity.IsAuthenticated working fine in my local but always return false after depoying the project in the server?

Lolita

Member
Joined
May 21, 2022
Messages
7
Programming Experience
1-3
Hello Team,
I am using C# Web Form application.
I am using the following code that is is working fine in my local machine:

class: ac.aspx.cs Page_Load:

protected void Page_Load(object sender, EventArgs e)
{
string crtUser = "";
if (User.Identity.IsAuthenticated)
{
crtUser = User.Identity.Name.Split('\\')[1];
Session["USER_ID"] = crtUser;
}
}

The issue is, after I deploy my code in the server User.Identity.IsAuthenticated it return false and I am not abel to get the Session["USER_ID"]

This is my web.config setting lines related to that:

<authentication mode="Forms">
<forms loginUrl="ac/ac.aspx" timeout="2880" />
</authentication>

<authorization>
<deny users="?"/>
</authorization>

<location path="ac/ac.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>

Can you please help on my issue, it is really appreciated
Have a great day
 
If anonymous authentication enabled for that site or virtual directory? If so there is your answer.
 
Try disabling anonymous.
 
Good morning Skydiver,
Thank you for your time.
When I disable anonymous I am getting :
Server Error
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.
 
Thanks for trying. In my experience t usually fixed things. I guess turn it back on, and then try to enable failed request tracing/logging in IIS. Hopefully there will be a hint in there
 
Back
Top Bottom