CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.security Tags:
Item Type: NewsGroup Date Entered: 7/5/2005 1:04:39 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 54 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
DonMJW
Asp.Net User
LoginView Control's ViewChanged Event does not fire7/5/2005 1:04:39 PM

0/0

I've been developing a website, which consists of a master page with the login view control added to it, with a login control within the anonymous template.  On the LoggedInTemplate, I display login specific details, one of which I manually change, due to it being application specific rather than a generic ASP .NET login feature.  The master page also contains a ContentPlaceHolder.

All of the pages within the website are based upon this master page, and have custom content, which in its simplist form is a login view control, with content defined for the Anonymous and Logged In Templates.  I have added code to handle the viewchanged event, and checked to ensure that the OnViewChanged attribute in the aspx files, and they all have the handles clause set.

The master page handles all of the authentication of the users, which works fine.  However, when a user logs in or out, the ViewChanged event never fires on any of the loginviews, irrespective of whether they are on the master page or on the content pages.  Originally, the website was created on Beta 1, and the event fired fine, but since going over to Beta 2 (Team System), this issue has arised.

Has anyone else experienced the same problem, and if so was there any resolution?

Thanks for any help anyone can provide.

Mike
farmas
Asp.Net User
Re: LoginView Control's ViewChanged Event does not fire7/5/2005 7:03:27 PM

0/0

Mike, the behaviour that you are describing is a design change from Beta1 to Beta2. Let me explain the new behaviour: the LoginView control will only trigger its changing events when the template to display is different than the template that it retrieved from ViewState. Think of it as the control loading a starting template upon the first request, the anonymous template if the request was anonymous or the LoggedInTemplate if the request was authenticated. In this case, the viewchange events are NOT triggered, because there was no previously selected template to change from, the control is just picking its starting template. If in a subsequent post the control needs to change templates, then the viewchange event is triggered (because its changing from the starting template to a new template).

I attach a sample page to exemplify.

1) The first time you hit the page (a GET request) the control chooses the AnonymousTemplate (no viewchange event)
2) If you click on the "Login and Refresh" button, you will set the formsauth ticket and redirect back to the same page, which is in essence another GET. There is no viewstate, so the control is back to where it started, it needs to choose again its starting template, and in this case (since the formsauth ticket is present) it will select the LoggedInTemplate (no viewchange event). This is what happens when log in with the Login control
3) Logout of the site
4) Click on "Login" button, this will set the formsauth ticket but WILL NOT redirect
5) Now click on "Refresh". In this case the control remembers that its starting template was the AnonymousTemplate, and now needs to change rendering to LoggedInTemplate, so it must trigger its ViewChange event.

Notice that the Login control by default will Log in and redirect, which is why you don't get the change events. The nest result of this change is that if you need to modify the contents of the templates of LoginView, you no longer need to do it on the ViewChange event (unless your application expects authentication status change to occur on mid-request or no redirects after authentication status change). Instead you can do it on the regular Page_Load() event, because at that time the control is garanteed to have the correct template loaded up.

Hope this helps,
Federico Silva
Web Platform & Tools QA Team

<script runat="server">

    protected void LoginView1_ViewChanged(object sender, EventArgs e)
    {
        Response.Write("<br>VIEWCHANGED");
    }

    protected void LoginView1_ViewChanging(object sender, EventArgs e)
    {
        Response.Write("<br>VIEWCHANGING");
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        FormsAuthentication.SetAuthCookie("farmas", false);
        Response.Redirect(Request.Path);
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        FormsAuthentication.SetAuthCookie("farmas", false);
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:LoginView ID="LoginView1" runat="server" OnViewChanged="LoginView1_ViewChanged" OnViewChanging="LoginView1_ViewChanging">
            <LoggedInTemplate>
                YOU ARE LOGGED IN
            </LoggedInTemplate>
            <AnonymousTemplate>
                YOU ARE ANONYMOUS
            </AnonymousTemplate>
        </asp:LoginView>
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Login & Refresh" />
        <asp:Button ID="Button2" runat="server" Text="Login" OnClick="Button2_Click" />&nbsp;<asp:Button ID="Button3"
            runat="server" Text="Refresh" /><br />
        <br />
    </div>
    </form>
</body>
</html>

DonMJW
Asp.Net User
Re: LoginView Control's ViewChanged Event does not fire7/6/2005 8:02:42 AM

0/0

Many thanks for the explanation, Federico, it is very useful for understanding this change.
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
LoginView Control's ViewChanged Event does not fire - ASP.NET Forums LoginView Control's ViewChanged Event does not fire .... TechNet Edge: What’s New in Mobility and Anywhere Access with Office Communications ...
LoginView Control's ViewChanged Event does not fire - ASP.NET Forums Re: LoginView Control's ViewChanged Event does not fire. 07-05-2005, 3:03 PM. Contact ... Re: LoginView Control's ViewChanged Event does not fire ...
creativeUI - .Net Membership - Part II - LoginView Oct 5, 2007 ... Still cannot get the ViewChanged and ViewChanging events to fire though ... say that’s not a requirement now that I can access the controls. ...
Membership You can also react to the ViewChanging and ViewChanged events of the LoginView control to initialize. your controls just before they become visible in the ...
TheMSsForum.com >> VB >> How to set value of SecureString? - The ... Does anyone ever tried and is there any way to control particular events (items) inside printer spooler(s) Any input will be appreciated! ...
[Mono] Log of /trunk/mcs/class/System.Web/System.Web.UI ... NET does, as some commercial ASP.NET controls take advantage of that via ...... Page.cs: VerifyRenderingInServerForm does not fire exception when IsCallback ...
[Mono] View of /trunk/mcs/class/System.Web/System.Web.UI ... The method makes it possible to find controls that reside in master pages. ..... throws exception if needed control not found * LoginView.cs: fixed ...




Search This Site:










web part code question

where's the magic

how do i configure the http handler on the iis ?

dnn 1.0.10c core enhancement: module sharing among tabs

masterpage and user control error

module visibility

cbo question

the best software to edit .asp file

getting the exception in custom error page!

wadsworth psk and gmail...

printing mailing labels

starting error

how do i enable/disable a control based on the value in another control

develop online surveys with web matrix projects

dnn 3.0.8: localization bug in page name

bug in image module (dnn 10e)

dnn 1 and search engines

timespan and years

what my server need for sqlserver database?

saving lot of text in the database sql server what datatype to use

unable to find script library '/aspnet_client/system_web/1_1_4322/webuivalidation.js

question about scripting.filesystemobject

can't create portal

containers got messed up somehow

set asp.net web control id

third column on the master page

'unsuccessful database connection' on install

how to format [currentdate] control

looking for implementation suggestions for "unread messages" feature

how to expire a user's authentication ticket?

 
All Times Are GMT