Initiating FormsAuthentication.SignOut() Isn't Working

Last post 10-31-2007 9:21 PM by JackDeth. 6 replies.

Sort Posts:

  • Initiating FormsAuthentication.SignOut() Isn't Working

    10-27-2007, 12:56 AM
    • Member
      point Member
    • JackDeth
    • Member since 06-03-2003, 6:28 PM
    • Posts 4

    I have a site with multiple datagrid pages. First there's the "main" page. One page, accessed from the "main" page shows a master list of records store in MS SQL. Then there's a page that allows the person to edit the records, and a page that allows the person to add new records.

     I have these pages protected with a login page. If the person tries to visit any of the pages it will automatically directed them to the login page to login. Once they enter a username and password it takes them back to the page they were trying to access.

     On each of these pages, I have created a logout link. The link is supposed to log them out, and then redirect them to a "logoff" page that thanks them, and the after 5 seconds, redirects them back to the main page where they could login again.

    The logout link works perfectly on every page except the Add Record page. That page is simply a form with blanks. They fill in the blanks and click submit and it enters the information into the database. When you click logoff, not only does it not redirect you to the logoff page, but the page just basically refreshes itself and leaves you exactly where you were. You are also not logged out. I cannot figure out why it doesn't work on just this page. I created another page with a form and tried it on that page with the same result. Is there a bug in .NET that won't allow a logoff link on a page with an input form?

     Here's my code:

     

    Main script

    <script type="text/javascript" runat="server">
    Private Sub logoff_Click(ByVal sender as System.Object, ByVal e As System.EventArgs)
        FormsAuthentication.SignOut()
        Response.Redirect("/logoff.aspx")
    End Sub
    </script>

     
    Logout link

    <asp:linkbutton ID="logoff" runat="server" Text="[logoff]" OnClick="logoff_Click" ></asp:linkbutton>

     

    Any ideas?
     

  • Re: Initiating FormsAuthentication.SignOut() Isn't Working

    10-29-2007, 8:00 AM
    • Contributor
      5,590 point Contributor
    • deblendewim
    • Member since 12-20-2006, 4:32 PM
    • Antwerp, Belgium
    • Posts 951

    JackDeth:
    <script type="text/javascript" runat="server">
    Private Sub logoff_Click(ByVal sender as System.Object, ByVal e As System.EventArgs)
        FormsAuthentication.SignOut()
        Response.Redirect("/logoff.aspx")
    End Sub
    </script>
     

    Your code is good actually but did you place it like this on your page????

    The code above is no "text/javascript" so I'm not sure it works this way!

     

    Kind regards,
    Wim

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: Initiating FormsAuthentication.SignOut() Isn't Working

    10-29-2007, 5:52 PM
    • Member
      point Member
    • JackDeth
    • Member since 06-03-2003, 6:28 PM
    • Posts 4

     I've tried it both with  type="text/javascript" and without and it makes no difference.

  • Re: Initiating FormsAuthentication.SignOut() Isn't Working

    10-30-2007, 4:20 AM

    Hi

    Please have a look at this link, I guess you had the same kind of problem

    http://p2p.wrox.com/topic.asp?TOPIC_ID=35992

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
    Best Regards
    XiaoYong Dai
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: Initiating FormsAuthentication.SignOut() Isn't Working

    10-30-2007, 6:17 PM
    • Member
      point Member
    • JackDeth
    • Member since 06-03-2003, 6:28 PM
    • Posts 4

     Similar problem, but not exactly the same thing. You see, the logout works on all pages except that page which has a form that is supposed to allow you to enter data into a database. Edit/Update page works fine, regular pages that display data - fine. I don't have anything like what they are referring to located in my web.config file, except maybe <forms name="SECAUTH" loginUrl="/ecomm/login.aspx" />, but that needs to be there.

     

    Here's my web.config:

     

    <!-- Web.Config Configuration File -->

    <configuration>

        <system.web>
            <customErrors mode="Off"/>
        </system.web>

        <appSettings>

            <add key="MM_CONNECTION_HANDLER_MLClogins" value="sqlserver.htm" />
            <add key="MM_CONNECTION_STRING_MLClogins" value="Persist Security Info=True;Data Source=sql01.datasource.com;Initial Catalog=DATABASE;User ID=ID;Password=PASSWORD" />
            <add key="MM_CONNECTION_DATABASETYPE_MLClogins" value="SQLServer" />
            <add key="MM_CONNECTION_SCHEMA_MLClogins" value="" />
            <add key="MM_CONNECTION_CATALOG_MLClogins" value="" />
           
            <add key="MM_CONNECTION_HANDLER_MLCevangelism" value="sqlserver.htm" />
            <add key="MM_CONNECTION_STRING_MLCevangelism" value="Persist Security Info=True;Data Source=sql01.datasource.com;Initial Catalog=DATABASE;User ID=ID;Password=PASSWORD" />
            <add key="MM_CONNECTION_DATABASETYPE_MLCevangelism" value="SQLServer" />
            <add key="MM_CONNECTION_SCHEMA_MLCevangelism" value="" />
            <add key="MM_CONNECTION_CATALOG_MLCevangelism" value="" />
           
        </appSettings>
           
        <!-- enable Forms authentication -->
        <system.web>    
            <authentication mode="Forms">
                <forms name="SECAUTH" loginUrl="/ecomm/login.aspx" />
            </authentication>
        </system.web>

        <!-- Require authorization for all files in the "ecomm" subdirectory.     -->
        <location path="ecomm">
            <system.web>    
                <authorization>
                    <deny users="?" />
                </authorization>
              </system.web>
        </location>

    <!-- DEBUGGING -->
        <system.web>
           <compilation debug="true"/>
        </system.web>
       
       
    </configuration>

  • Re: Initiating FormsAuthentication.SignOut() Isn't Working

    10-31-2007, 3:08 AM

    JackDeth:

    except the Add Record page. That page is simply a form with blanks. They fill in the blanks and click submit and it enters the information into the database. When you click logoff, not only does it not redirect you to the logoff page, but the page just basically refreshes itself and leaves you exactly where you were.

    Hi

    I had taken part in Asset Manage System project and programmed similar module, your problem looks weird. It would be great if you can paste your "Add" page for investigation.

    Best Regards
    XiaoYong Dai
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: Initiating FormsAuthentication.SignOut() Isn't Working

    10-31-2007, 9:21 PM
    • Member
      point Member
    • JackDeth
    • Member since 06-03-2003, 6:28 PM
    • Posts 4

    XiaoYong Dai – MSFT:

    Hi

    I had taken part in Asset Manage System project and programmed similar module, your problem looks weird. It would be great if you can paste your "Add" page for investigation.

     

     

    <%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
    <%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
    <%@ Assembly src="/includes/MM_XSLTransform/MM_XSLTransform.vb" %>

    <MM:Insert
    runat="server"
    CommandText='<%# "INSERT INTO dbo.prospect_list (lastname, firstname, address, city, ""state"", zip, phone, email, homechurch, notes, firstdate, lastdate) VALUES (@lastname, @firstname, @address, @city, @state, @zip, @phone, @email, @homechurch, @notes, @firstdate, @lastdate)" %>'
    ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_EXAMPLE") %>'
    DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_EXAMPLE") %>'
    Expression='<%# Request.Form("MM_insert") = "prospect_add" %>'
    CreateDataSet="false"
    SuccessURL='<%# "/ecomm/prospects_add.aspx" %>'
    Debug="true" >

    <Parameters>
    <Parameter Name="@lastname" Value='<%# IIf((Request.Form("lastname") <> Nothing), Request.Form("lastname"), "") %>' Type="VarChar" />
    <Parameter Name="@firstname" Value='<%# IIf((Request.Form("firstname") <> Nothing), Request.Form("firstname"), "") %>' Type="VarChar" />
    <Parameter Name="@address" Value='<%# IIf((Request.Form("address") <> Nothing), Request.Form("address"), "") %>' Type="VarChar" />
    <Parameter Name="@city" Value='<%# IIf((Request.Form("city") <> Nothing), Request.Form("city"), "") %>' Type="VarChar" />
    <Parameter Name="@state" Value='<%# IIf((Request.Form("state") <> Nothing), Request.Form("state"), "") %>' Type="VarChar" />
    <Parameter Name="@zip" Value='<%# IIf((Request.Form("zip") <> Nothing), Request.Form("zip"), "") %>' Type="VarChar" />
    <Parameter Name="@phone" Value='<%# IIf((Request.Form("phone") <> Nothing), Request.Form("phone"), "") %>' Type="VarChar" />
    <Parameter Name="@email" Value='<%# IIf((Request.Form("email") <> Nothing), Request.Form("email"), "") %>' Type="VarChar" />
    <Parameter Name="@homechurch" Value='<%# IIf((Request.Form("homechurch") <> Nothing), Request.Form("homechurch"), "") %>' Type="VarChar" />
    <Parameter Name="@notes" Value='<%# IIf((Request.Form("notes") <> Nothing), Request.Form("notes"), "") %>' Type="VarChar" />
    <Parameter Name="@firstdate" Value='<%# IIf((Request.Form("firstdate") <> Nothing), Request.Form("firstdate"), "") %>' Type="VarChar" />
    <Parameter Name="@lastdate" Value='<%# IIf((Request.Form("lastdate") <> Nothing), Request.Form("lastdate"), "") %>' Type="VarChar" />
    </Parameters>
    </MM:Insert>
    <MM:DataSet
    id="prospect_list"
    runat="Server"
    IsStoredProcedure="false"
    ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_EXAMPLE") %>'
    DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_EXAMPLE") %>'
    CommandText='<%# "SELECT dbo.prospect_list.prospect_id, dbo.prospect_list.firstname, dbo.prospect_list.address, dbo.prospect_list.city, dbo.prospect_list.""state"", dbo.prospect_list.zip, dbo.prospect_list.phone, dbo.prospect_list.email, dbo.prospect_list.homechurch, dbo.prospect_list.notes, dbo.prospect_list.firstdate, dbo.prospect_list.lastdate  FROM dbo.prospect_list" %>'
    Debug="true"
    >
    <EditOps>
    <EditOpsTable Name="dbo.prospect_list" />
    <Parameter Name="prospect_id" Type="Int" IsPrimary="true" />
    </EditOps>
    </MM:DataSet>
    <MM:PageBind runat="server" PostBackBind="true" />

    <html><!-- InstanceBegin template="/Templates/one_column_protected.dwt.aspx" codeOutsideHTMLIsLocked="false" -->
    <head>

    <script type="text/javascript" runat="server">
    Private Sub logoff_Click(ByVal sender as System.Object, ByVal e As System.EventArgs)
        FormsAuthentication.SignOut()
        Response.Redirect("/logoff.aspx")
    End Sub
    </script>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Martin Luther Church Ministry Teams</title>
    <!-- InstanceEndEditable -->
    <META NAME="ROBOTS" CONTENT="NONE">

    <!-- InstanceBeginEditable name="head" -->

    <link href="/css/styles.css" rel="stylesheet" type="text/css" />
    <link href="/css/dropshadow.css" rel="stylesheet" type="text/css" />



    <!-- InstanceEndEditable -->
    </head>

    <body>
    <table align="center" class="navcell">
    <tr>
    <td class="banner">&nbsp;</td>
    </tr>
    <tr>
    <td><!--#include file="../navigation_inc.html" --></td>
    </tr>
    <tr>
    <td class="maintext">


    <!-- InstanceBeginEditable name="Main" -->
    <table width="100%">
    <tr>
    <td>
    <form runat="server">

    <table width="100%">
    <tr>
    <td><h1>Add Prospect </h1></td>
    </tr>
    <tr>
    <td class="logoff">
    <asp:linkbutton ID="logoff" runat="server" Text="[logoff]" OnClick="logoff_Click" ></asp:linkbutton>
    </td>
    </tr>
    <tr>
    <td>

    <div id="shadow-container">
    <div class="shadow1">
    <div class="shadow2">
    <div class="shadow3">
    <div class="container">
    <table width="100%" border="0" cellpadding="0" cellspacing="5" class="prosform" Text='<%# prospect_list.FieldValue("firstname", Container) %>' runat="server">
    <tr>
    <td valign="top"><p align="right">Last Name </p></td>
    <td valign="top"><p>
    <asp:TextBox BackColor="#FFFFFF" BorderColor="#999999" BorderWidth="1" Columns="1" ID="lastname" runat="server" TextMode="SingleLine" Wrap="false" class="datagridbox" />
    </p></td>
    </tr>
    <tr>
    <td valign="top"><p align="right">First Name </p></td>
    <td valign="top"><p>
    <asp:TextBox BackColor="#FFFFFF" BorderColor="#999999" BorderWidth="1" Columns="1" ID="firstname" runat="server" TextMode="SingleLine" Wrap="false" class="datagridbox" />
    </p></td>
    </tr>
    <tr>
    <td valign="top"><p align="right">Address</p></td>
    <td valign="top"><p>
    <asp:TextBox BackColor="#FFFFFF" BorderColor="#999999" BorderWidth="1" Columns="1" ID="address" runat="server" TextMode="SingleLine" Wrap="false" class="datagridbox" />
    </p></td>
    </tr>
    <tr>
    <td valign="top"><p align="right">City</p></td>
    <td valign="top"><p>
    <asp:TextBox BackColor="#FFFFFF" BorderColor="#999999" BorderWidth="1" Columns="1" ID="city" runat="server" TextMode="SingleLine" Wrap="false" class="datagridbox" />
    </p></td>
    </tr>
    <tr>
    <td valign="top"><p align="right">State</p></td>
    <td valign="top"><p>
    <asp:TextBox BackColor="#FFFFFF" BorderColor="#999999" BorderWidth="1" Columns="1" ID="state" runat="server" TextMode="SingleLine" Wrap="false" class="datagrid50" />
    </p></td>
    </tr>
    <tr>
    <td valign="top"><p align="right">ZIP</p></td>
    <td valign="top"><p>
    <asp:TextBox BackColor="#FFFFFF" BorderColor="#999999" BorderWidth="1" Columns="1" ID="zip" runat="server" TextMode="SingleLine" Wrap="false" class="datagrid100" />
    </p></td>
    </tr>
    <tr>
    <td valign="top"><p align="right">Phone</p></td>
    <td valign="top"><p>
    <asp:TextBox BackColor="#FFFFFF" BorderColor="#999999" BorderWidth="1" Columns="1" ID="phone" runat="server" TextMode="SingleLine" Wrap="false" class="datagrid175" />
    </p></td>
    </tr>
    <tr>
    <td valign="top"><p align="right">Email</p></td>
    <td valign="top"><p>
    <asp:TextBox BackColor="#FFFFFF" BorderColor="#999999" BorderWidth="1" Columns="1" ID="email" runat="server" TextMode="SingleLine" Wrap="false" class="datagridbox" />
    </p></td>
    </tr>
    <tr>
    <td valign="top"><p align="right">Home Church </p></td>
    <td valign="top"><p>
    <asp:TextBox BackColor="#FFFFFF" BorderColor="#999999" BorderWidth="1" Columns="1" ID="homechurch" runat="server" TextMode="SingleLine" Wrap="false" class="datagridbox" />
    </p></td>
    </tr>
    <tr>
    <td valign="top"><p align="right">Notes</p></td>
    <td valign="top"><p>
    <asp:TextBox BackColor="#FFFFFF" BorderColor="#999999" BorderWidth="1" ID="notes" Rows="5" runat="server" TextMode="MultiLine" class="datagrid300" /></p></td>
    </tr>
    <tr>
    <td valign="top"><p align="right">First Date Visited </p></td>
    <td valign="top"><p>
    <asp:TextBox BackColor="#FFFFFF" BorderColor="#999999" BorderWidth="1" Columns="1" ID="firstdate" runat="server" TextMode="SingleLine" Wrap="false" class="datagrid100" />
    </p></td>
    </tr>
    <tr>
    <td valign="top"><p align="right">Last Known Date Visited </p></td>
    <td valign="top"><p>
    <asp:TextBox BackColor="#FFFFFF" BorderColor="#999999" BorderWidth="1" Columns="1" ID="lastdate" runat="server" TextMode="SingleLine" Wrap="false" class="datagrid100" />
    </p></td>
    </tr>
    <tr>
    <td valign="top">&nbsp;</td>
    <td valign="top"><div align="right">
    <input type="submit" name="Submit" value="Submit" />
    </div></td>
    </tr>
    </table></div>
    </div>
    </div>
    </div>
    </div>

    </td>
    </tr>
    <tr>
    <td>

    <table border="0" cellpadding="5" cellspacing="5">
    <tr>
    <td valign="bottom" class="prosnav"><a href="/ecomm/prospects.aspx" target="_top">View Master List</a></td>
    <td valign="bottom" class="prosnav"><a href="/ecomm/prospects_edit.aspx" target="_top">Edit List</a></td>
    </tr>
    </table>

    </td>
    </tr>
    </table>
    <input type="hidden" name="MM_insert" value="prospect_add" />
    </form>
    </td>
    </tr>
    </table>
    <!-- InstanceEndEditable -->
    </td>
    </tr>
    </table>
    </body>

    <!-- InstanceEnd --></html>
     

Page 1 of 1 (7 items)