C# 什么';重定向到login.aspx的安全方法是什么?

C# 什么';重定向到login.aspx的安全方法是什么?,c#,asp.net,C#,Asp.net,现在我正在从头开始编写一个ASP.NET web应用程序,我希望所有未登录的用户都被重定向到Login.aspx。以下是我的母版页中的代码: protected override void OnInit(EventArgs e) { base.OnInit(e); if (this.Session["User"] == null && !this.Request.Path.EndsWith("Login.aspx")) { Response.Red

现在我正在从头开始编写一个ASP.NET web应用程序,我希望所有未登录的用户都被重定向到
Login.aspx
。以下是我的母版页中的代码:

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    if (this.Session["User"] == null && !this.Request.Path.EndsWith("Login.aspx")) {
        Response.Redirect("Login.aspx", true);
    }
}

然而,我担心潜在的恶意用户可能会通过输入
https://mywebsite.com/Default.aspx?id=Login.aspx
。在调试器中,它似乎不包含额外的参数,但我想知道用户是否有任何方法可以操纵它来查看其他页面。我的问题是,像这样使用
Request.Path
安全吗?

无需重新发明轮子,ASP.NET内置了这样的功能:

调查


无需重新发明轮子,ASP.NET具有以下内置功能:

调查


无需重新发明轮子,ASP.NET具有以下内置功能:

调查


无需重新发明轮子,ASP.NET具有以下内置功能:

调查


按照@meda的建议更改web.config后 试试这个

if (!User.Identity.IsAuthenticated)
    {
       Response.Redirect("Login.aspx", true);
    }

按照@meda的建议对web.config进行更改后 试试这个

if (!User.Identity.IsAuthenticated)
    {
       Response.Redirect("Login.aspx", true);
    }

按照@meda的建议对web.config进行更改后 试试这个

if (!User.Identity.IsAuthenticated)
    {
       Response.Redirect("Login.aspx", true);
    }

按照@meda的建议对web.config进行更改后 试试这个

if (!User.Identity.IsAuthenticated)
    {
       Response.Redirect("Login.aspx", true);
    }

为什么不使用
web.config
?您研究过表单身份验证吗?为什么不使用
web.config
?您研究过表单身份验证吗?为什么不使用
web.config
?您研究过表单身份验证吗?为什么不使用
web.config
?您研究过表单身份验证吗?