Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Adobe Tutorial Help please?

Guest
Jun 15, 2006 Jun 15, 2006
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
TOPICS
Server side applications
283
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 15, 2006 Jun 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 t...
Translate
LEGEND ,
Jun 15, 2006 Jun 15, 2006
LATEST
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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines