Skip to main content
June 15, 2006
Answered

Adobe Tutorial Help please?

Hi,

Trying to do the tutorial but have no idea of C#. I have tried running the code through a convertor but keep getting errors. Can anyone convert this from C# to VB

<script runat="server">
protected void Page_Load(Object Src, EventArgs E)
{
// Don't cache this page.
Response.Expires = -1;
Response.AddHeader("Pragma", "no-cache");
Response.AddHeader("cache-control", "no-store");

if (IsPostBack)
{
// Check user credentials entered on the page
if ((emailaddr.Value == DS_uidAndPwd.FieldValue("emailaddr",null)) && (password.Value == DS_uidAndPwd.FieldValue("password",null)))
{
// The user has been authenticated.
// 1. Create the authentication ticket.
// 2. Redirect to the appropriate page.

// 1. Create the authentication ticket.
// Create and use the forms authentication ticket.
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
Request.Form["emailaddr"],
DateTime.Now, // issue time
DateTime.Now.AddMinutes(30), // expires in 30 minutes
false, // not persistent
"member"); // role assignment gets stored in the UserData

// Create a new (encrypted) HttpCookie using the ticket just created
// and name it accordingly to the value specified in the <forms> element
// in the web.config file.
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));

// Add the cookie to the outbound response.
Response.Cookies.Add(cookie);

// Redirect as appropriate.
String returnUrl;
if (Request.QueryString["ReturnURL"] == null)
{
returnUrl = "/members/index.aspx";
}
else
{
returnUrl = Request.QueryString["ReturnURL"];
}
Response.Redirect(returnUrl);

}
else
{
Msg.Text = "Invalid Credentials: Please try again";
}
}
}
</script>

Many Thanks
This topic is closed to new replies. Start a new post to keep the conversation going.
Newsgroup_UserCorrect answer
Inspiring
June 15, 2006
Here you go, looks wrong though, the line:

If True Then

will always evaluate as true, that your are saying here is:

if true = true then

which leaves the else block a pointless exercise because its always going to
be true


<script language="VB" runat=server>
Protected Sub Page_Load(ByVal Src As Object, ByVal E As EventArgs)
If Page.IsPostBack Then
' authenticate user
' NOTE: how this check is done and a discussion of what happens
is discussed in the
' next two sections: Authenticate the login credentials and
' Create the FormsAuthenticationTicket (with
RedirectFromLoginPage).
If True Then
FormsAuthentication.RedirectFromLoginPage(emailaddr.Value,
False)
Else
Msg.Text = "Invalid Credentials: Please try again"
End If
End If
End Sub
</script>

--
Kevin Marshall
WebXeL.com Ltd
http://www.webxel.com

ASP.NET Dreamweaver Extensions
http://www.webxel-dw.co.uk

"ricky0110" <webforumsuser@macromedia.com> wrote in message
news:e6ron9$6u9$1@forums.macromedia.com...
> Hi,
>
> Trying to do the tutorial but have no idea of C#. I have tried running the
> code through a convertor but keep getting errors. Can anyone convert this
> from
> C# to VB
>
> <script language="C#" runat=server>
> protected void Page_Load(Object Src, EventArgs E)
> {
> if (IsPostBack)
> {
> // authenticate user
> // NOTE: how this check is done and a discussion of what happens is
> discussed in the
> // next two sections: Authenticate the login credentials and
> // Create the FormsAuthenticationTicket (with
> RedirectFromLoginPage).
> if (true)
> {
> FormsAuthentication.RedirectFromLoginPage(emailaddr.Value,
> false);
> }
> else
> {
> Msg.Text = "Invalid Credentials: Please try again";
> }
> }
> }
> </script>
>
>
> Many Thanks
>


1 reply

Newsgroup_UserCorrect answer
Inspiring
June 15, 2006
Here you go, looks wrong though, the line:

If True Then

will always evaluate as true, that your are saying here is:

if true = true then

which leaves the else block a pointless exercise because its always going to
be true


<script language="VB" runat=server>
Protected Sub Page_Load(ByVal Src As Object, ByVal E As EventArgs)
If Page.IsPostBack Then
' authenticate user
' NOTE: how this check is done and a discussion of what happens
is discussed in the
' next two sections: Authenticate the login credentials and
' Create the FormsAuthenticationTicket (with
RedirectFromLoginPage).
If True Then
FormsAuthentication.RedirectFromLoginPage(emailaddr.Value,
False)
Else
Msg.Text = "Invalid Credentials: Please try again"
End If
End If
End Sub
</script>

--
Kevin Marshall
WebXeL.com Ltd
http://www.webxel.com

ASP.NET Dreamweaver Extensions
http://www.webxel-dw.co.uk

"ricky0110" <webforumsuser@macromedia.com> wrote in message
news:e6ron9$6u9$1@forums.macromedia.com...
> Hi,
>
> Trying to do the tutorial but have no idea of C#. I have tried running the
> code through a convertor but keep getting errors. Can anyone convert this
> from
> C# to VB
>
> <script language="C#" runat=server>
> protected void Page_Load(Object Src, EventArgs E)
> {
> if (IsPostBack)
> {
> // authenticate user
> // NOTE: how this check is done and a discussion of what happens is
> discussed in the
> // next two sections: Authenticate the login credentials and
> // Create the FormsAuthenticationTicket (with
> RedirectFromLoginPage).
> if (true)
> {
> FormsAuthentication.RedirectFromLoginPage(emailaddr.Value,
> false);
> }
> else
> {
> Msg.Text = "Invalid Credentials: Please try again";
> }
> }
> }
> </script>
>
>
> Many Thanks
>


Translate