LoggedInTemplate Not displayed

我怕爱的太早我们不能终老 提交于 2019-12-11 20:09:25

问题


I am using ASP.Net Membership to handle Login for our site. We have the tables setup on SQL Server, here is the Web.config

 <connectionStrings>
<add name="OurWorldLoginEntities" connectionString="metadata=res://*/OurWorld.csdl|res://*/OurWorld.ssdl|res://*/OurWorld.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost\localinstance;initial catalog=OurWorldLogin;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />
<add name="OurWorld" connectionString="data source=localhost\localinstance;initial catalog=OurWorldLogin;integrated security=True;" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<machineKey validationKey="5256BC27E9181A907DC7962870585DD622CD41ABB636020F0642AA238C0AA3B1614D367F62DBD51F5B3D7EB5734F4EC3915F957EC0C2E01152EE48D24FDEA721" decryptionKey="BEA903A316F9CF06C0739C4AB9075EF97F0C2B05C8129FB8" validation="SHA1"/>
<profile enabled="true" automaticSaveEnabled="true" defaultProvider="SqlProfileProvider">
  <providers>
    <add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="OurWorld" applicationName="Inside.leadingRE.com" />
  </providers>
</profile>
<membership defaultProvider="SqlMembershipProvider">
  <providers>
    <add name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="OurWorld"
         minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" enablePasswordRetrieval="true" enablePasswordReset="true"
         requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Encrypted" maxInvalidPasswordAttempts="10" passwordAttemptWindow="30"
         applicationName="Inside.leadingRE.com" passwordStrengthRegularExpression="" />
  </providers>
</membership>
<roleManager defaultProvider="SqlRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES"
             cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true"
             cookieProtection="All">
  <providers>
    <add name="SqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="OurWorld"
         applicationName="Inside.LeadingRE.com" />
  </providers>
</roleManager>
</system.web>

The site has a MasterPage that has the LoginView Control

 <table cellpadding="0" cellspacing="0" border="0" align="center" style="width: 100%">

        <asp:LoginView ID="lv_LoginView" runat="server">
            <AnonymousTemplate>
                <tr>
                    <td align="center">
                        <asp:ContentPlaceHolder ID="ContentPlaceHolderAnonymous" runat="server"></asp:ContentPlaceHolder>
                    </td>
                </tr>
            </AnonymousTemplate>
            <LoggedInTemplate>
                <tr>
                    <td>
                        <asp:ContentPlaceHolder ID="ContentPlaceHolderLoggedIn" runat="server"></asp:ContentPlaceHolder>
                    </td>
                </tr>
            </LoggedInTemplate>
        </asp:LoginView>
    </table>

The Login.aspx page has a user id and password field that on successful login sends the user to Default.aspx where I have this page

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderAnonymous" runat="server">
Not Logged In
</asp:Content>
 <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderLoggedIn"      runat="server">
     Logged In
</asp:Content>

The issue is that I get directed over there, but the Anonymous Template only displays. I am not sure what is going on here, as it is a pretty much copy/paste from the MSDN walkthrough.

On a side note, is there a way to not redirect to Default.aspx, but stay on the same page if it is a successful Login, but just shows the LoggedInTemplate?

来源:https://stackoverflow.com/questions/18624055/loggedintemplate-not-displayed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!