Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
Tradução
Original
Este tópico ainda não foi avaliado como - Avalie este tópico

FormsAuthentication.RedirectFromLoginPage Método (String, Boolean)

Redireciona uma usuário autenticado Voltar o URL originalmente solicitada ou a usar como padrão URL.

Namespace:  System.Web.Security
Assembly:  System.Web (em System.Web. dll)

public static void RedirectFromLoginPage(
	string userName,
	bool createPersistentCookie
)

Parâmetros

userName
Tipo: System.String

Login do usuário autenticado.

createPersistentCookie
Tipo: System.Boolean

true to create a durable cookie (one that is saved across browser sessions); otherwise, false.

ExceçãoCondição
HttpException

O URL de retorno especificado na seqüência de caracteres da consulta contém um protocolo diferente de HTTP: ou HTTPS:.

O método RedirectFromLoginPage redireciona para o URL especificado na query string usando o nome da variável ReturnURL.For example, in the URL http://www.contoso.com/login.aspx?ReturnUrl=caller.aspx, the RedirectFromLoginPage method redirects tothe return URL caller.aspx.If the ReturnURL variable does not exist, the RedirectFromLoginPage method redirects to the URL in the DefaultUrl property.

O ASP.NET adiciona automaticamente a URL de retorno quando o navegador é redirecionado para a página de logon.

By default, the ReturnUrl variable must refer to a page within the current application.If ReturnUrl refers to a page in a different application or on a different server, the RedirectFromLoginPage methods redirects to the URL in the DefaultUrl property.If you want to allow redirects to a page outside the current application, you must set the EnableCrossAppRedirects property to true using the enableCrossAppRedirects attribute of the forms configuration element.

Observação de segurança:

Setting the EnableCrossAppRedirects property to true to allow cross-application redirects is a potential security threat.Quando são permitidos redirecionamentos em aplicativos cruzados, seu site é vulnerável a sites mal-intencionados da Web que usam a página de login para convencer os usuários do site que estão usando uma página segura no seu site.To improve security when using cross-application redirects, you should override the RedirectFromLoginPage method to allow redirects only to approved Web sites.

If the CookiesSupported property is true, and either the ReturnUrl variable is within the current application or the EnableCrossAppRedirects property is true, then the RedirectFromLoginPage method issues an authentication ticket and places it in the default cookie using the SetAuthCookie method.

If CookiesSupported is false and the redirect path is to a URL in the current application, the ticket is issued as part of the redirect URL.If CookiesSupported is false, EnableCrossAppRedirects is true, and the redirect URL does not refer to a page within the current application, the RedirectFromLoginPage method issues an authentication ticket and places it in the QueryString property.

O exemplo de código a seguir redireciona usuários validados para a URL originalmente solicitada ou a DefaultUrl.O exemplo de código utiliza os usuários do ASP.NET para validar os usuários.Para obter mais informações sobre usuários do ASP.NET, consulte Gerenciando usuários usando Associação.

Observação de segurança:

Este exemplo contém uma caixa de texto que aceita entradas de usuário, o que é uma ameaça potencial à segurança.Por padrão, páginas Web ASP.NET validam se as entradas de usuário não incluem scripts ou elementos HTML.Para mais informações, acesse Visão Geral de Scripts Maliciosos.

<%@ Page Language= %>
<%@ Import Namespace= %>

<!DOCTYPE html PUBLIC "-
    "http:
<script runat=>

  Login_OnClick(object sender, EventArgs args)
{
    (Membership.ValidateUser(UsernameTextbox.Text, PasswordTextbox.Text))
      FormsAuthentication.RedirectFromLoginPage(UsernameTextbox.Text, NotPublicCheckBox.Checked);
   
     Msg.Text = ;
}


</script>

<html xmlns="http:
<head>
  <title>Login</title>
</head>
<body>

<form id= runat=>
  <h3>Login</h3>

  <asp:Label id= ForeColor= runat= /><br />

  Username: <asp:Textbox id= runat= /><br />
  Password: <asp:Textbox id= runat= TextMode= /><br />

  <asp:Button id= Text= OnClick= runat= />
  <asp:CheckBox id= runat= /> 
  Check here    <span style=>not</span> a  computer.

</form>

</body>
</html>


Isso foi útil para você?
(1500 caracteres restantes)

Contribuições da comunidade

ADICIONAR
A Microsoft está realizando uma pesquisa online para saber sua opinião sobre o site do MSDN. Se você optar por participar, a pesquisa online lhe será apresentada quando você sair do site do MSDN.

Deseja participar?
© 2013 Microsoft. Todos os direitos reservados.