[英]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 that the user does not have access to default2.aspx
unless they are logged in?如果我对另一个页面执行Response.Redirect()
假设default2.aspx
- 我如何确保用户无权访问default2.aspx
,除非他们已登录?
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. eg当用户成功登录时触发LoggedIn
事件。例如
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.编辑:参考您的评论,如果您在 web.config 的<configuration>
部分下添加以下代码,它将确保unauthenticated
身份验证的用户无法访问您的页面。
<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..如果您想保护您的文件夹免受unauthenticated
的用户的侵害,请这样做......
<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.确保您在 web.config 中有一个授权部分,并带有<deny users="?"/>
这可以防止未经身份验证的用户访问您的站点。
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. Forms auth 确实有办法重定向到不同的页面,但我不确定你是如何使用登录控件的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.