on login display a different page
right now when a user logs in, they see specific content on that same page:
<asp:LoginView ID="LoginView" runat="server">
<AnonymousTemplate>
Please login <br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:qcvalues_testConnectionString %>"
SelectCommand="SELECT * FROM [batchinfo]"></asp:SqlDataSource>
<asp:Login ID="LoginControl" runat="server" />
</AnonymousTemplate>
<LoggedInTemplate> you are logged in </LoggedInTemplate> ................
if i do Response.Redirect()
to another page let's say default2.aspx
- how do i ensure tha开发者_StackOverflowt the user does not have access to default2.aspx
unless they are logged in?
however i would like the user to be directed to a different page when they are logged in.
LoggedIn
event fired, when user is successfully logged in. e.g.
protected void Login1_LoggedIn(object sender, EventArgs e)
{
Response.Redirect("Page.aspx");
}
Edit: Referring to your comment, if you add the below code under the <configuration>
section of the web.config, it will make sure, that the unauthenticated
user will not have access to your page.
<location path="FolderNameIfAny/Page.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
If you want protect your folder from unauthenticated
users, do so like..
<configuration>
......................
......................
<location path="FolderName1">
<system.web>
<authorization>
<deny users="?"/>
<allow roles="role1"/>
</authorization>
</system.web>
</location>
<location path="FolderName2">
<system.web>
<authorization>
<deny users="?"/>
<allow roles="role2,role3IfAny"/>
</authorization>
</system.web>
</location>
</configuration>
You can allow specific roles to access to specific folder.
ensure you have an authorisation section in your web.config with <deny users="?"/>
That prevents unauthenticated users accessing your site.
Forms auth does have a way to redirect to a different page, but i'm not sure how you do it using the login control.
精彩评论