Firefox .net user authentication not working
I want the TaskBar object to be hidden when someone is not logged in
Here's my code:
if (HttpContext.Current.User.Identity.IsAuthenticated == false){TaskBar.Visible = false;}
This works perfectly in IE and Chrome, but for some reason, the TaskBar still shows up in Firefox when no one is logged in. I tried clearing firefox's cache, hoping that that was it, but it wasn't. Is there a more "cross-browser" friendly way of doing this?
[EDIT] The taskbar is a custom user control that I made, and uses no javascript. I just want to set its visibility to false.
[EDIT 2] Here's the code for the taskbar. Its been edited quite a bit for anonymity, so try and keep that in mind. And there are even more user controls attached to it. I'm not going to post the code for those, because I'm not the one who programmed them.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TaskBar.ascx.cs" Inherits="~.TaskBar" %>
<%@ Register TagPrefix="act" TagName="CallPopup" Src="~/Call.ascx" %>
<%@ Register TagPrefix="act" TagName="EmailPopup" Src="~/Email.ascx" %>
<%@ Register TagPrefix="act" TagName="NotePopup" Src="~/Note.ascx" %>
<%@ Register TagPrefix="act" TagName="SurveyPopup" Src="~/Survey.ascx" %>
<%@ Register TagPrefix="act" TagName="TaskPopup" Src="~/Task.ascx" %>
<style type="text/css">
.navBar
{
width: 100%;
height: 45px;
background-image: url(~/background.jpg);
background-repeat: repeat-x;
overflow: hidden;
text-align: center;
}
.navBar h2
{
float: left;
color: White;
width: 350px;
text-shadow: 2px 2px 2px #000;
}
.links
{
float: right;
}
.links a
{
padding-bottom: 5px;
}
.links img:hover
{
-moz-opacity:.50;
filter:alpha(opacity=50);
opacity:.50;
}
</style>
<div class="navBar">
<h2><asp:Label ID="label" runat="server" Text=""></asp:Label></h2>
<div class="links">
<asp:ImageButton runat="server" ID="tasksButton" ImageUrl="~/check.png" />
<img src="~/splitter.png" alt="" border="0" />开发者_开发问答
<a href="Home" id="homeButton"><img src="~/home.png" alt="" title="Return to the Home Page" border="0" /></a>
<a href="#" id="callButton"><img src="~/phone.png" alt="" title="Log a Call" border="0" /></a>
<act:CallPopup ID="pcCall" runat="server" />
<a href="#" id="emailButton"><img src="~/mail.png" alt="" title="Compose Email" border="0" /></a>
<act:EmailPopup ID="pcEmail" runat="server" />
<a href="#" id="noteButton"><img src="~/note.png" alt="" title="Add a Note" border="0" /></a>
<act:NotePopup ID="pcNote" runat="server" />
<a href="#" id="newTaskButton"><img src="~/task.png" alt="" title="Add a Task" border="0" /></a>
<act:TaskPopup ID="pcTask" runat="server" />
</div>
</div>
[EDIT 3]
Alright, so here's a bit more on the issue that I just figured out. The way the program is set up is so that users are able to check "Keep Me Logged In", which the program will then do. So I think the issue is actually that Firefox isn't letting the user logout. I have tried clicking our Logout button, and it only doesn't work in Firefox. Maybe that will help push this question forward.
Here's the code for the logout:
<asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/Login.aspx" />
We're using a basic AnonymousTemplate and LoggedInTemplate system. (I'm not completely sure what all else is needed to describe the login system, sorry...still new at this)
Have you used something like Fiddler or Firebug to check whether Firefox is sending the authentication cookie and whether logging out is clearing the cookie correctly?
HttpContext.Current.User.Identity.IsAuthenticated == false
is perfectly valid for checking if the user is authenticated.
Simon
The issue is a Javascript error elsewhere in the page, and its not allowing the user to click the logout button, therefore no cookies are being cleared or postbacks occuring. I'm closing this question, since it's no longer relevant.
精彩评论