[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

Forms Authentication, RedirectToLoginPage method

Murat UCUNCU

4/8/2002 10:07:00 PM

Hi,
I have been trying to redirect all mobile page requests to a login page for
unauthenticated requests using Forms Authentication. After directed and
having entered the login information in the login page, I use
RedirectToLoginPage() method, but,nothing seems to happen. All the data I
entered in the textbox just disappears but I still remain at the same login
page. Is there a way to help me out? Below is the code I used.

Thanks alot

Murat Ucuncu
----------------------------------------------------------------------------
----------------------
LOGIN.ASPX FILE
public class MobileWebForm1 : System.Web.UI.MobileControls.MobilePage{

protected System.Web.UI.MobileControls.TextBox Username; protected
System.Web.UI.MobileControls.TextBox Password;

protected System.Web.UI.MobileControls.Command CmdLogin; protected
System.Web.UI.MobileControls.Form formauth;



private void login_Click(object sender, System.EventArgs e){

String RedirectURL =
FormsAuthentication.GetRedirectUrl(Username.Text,false);

if (FormsAuthentication.Authenticate(Username.Text,Password.Text))

this.RedirectToMobilePage(RedirectURL);

else

Username.Text="ERROR!!"; }

}



AND WEB.CONFIG FILE .................

<authentication mode="Forms">

<forms name="CSGMISAuth" path="/" loginUrl="login.aspx" protection="All"
timeout="60">

<credentials passwordFormat="Clear">

<user name="user" password="password"> </user>

</credentials>

</forms>

</authentication>

<authorization> <deny users="?" /> </authorization>



3 Answers

Craig Deelsnyder

4/9/2002 1:31:00 AM

0

I had a similar problem, which did not make sense. Make one of your fields
(textboxes, etc.) AutoPostBack=true. My problem was that if you look in the
source of the page with the problem in the browser, I had no __doPostBack()
JavaScript function (ASP.NET didn't put one in). My form's
action="logon.aspx" was submitting the form back to my page when I hit
'Submit', but since it wasn't doing a __doPostBack, my button code was never
run (no event args were sent with the request). It simply did a Page_Load
and redisplayed since I didn't want to handle a POST request type
explicitly.

Setting AutoPostBack=true for one of the fields would put it in there.

Does anyone know why, or is this there a more correct explanation/fix?
Having to do that extra server hit for the field with AutoPostBack=true is
not necessary and annoying.


"Murat UCUNCU" <m_ucuncu@hotmail.com> wrote in message
news:eKCgTjz3BHA.2816@tkmsftngp05...
> Hi,
> I have been trying to redirect all mobile page requests to a login page
for
> unauthenticated requests using Forms Authentication. After directed and
> having entered the login information in the login page, I use
> RedirectToLoginPage() method, but,nothing seems to happen. All the data I
> entered in the textbox just disappears but I still remain at the same
login
> page. Is there a way to help me out? Below is the code I used.
>
> Thanks alot
>
> Murat Ucuncu
> --------------------------------------------------------------------------
--
> ----------------------
> LOGIN.ASPX FILE
> public class MobileWebForm1 : System.Web.UI.MobileControls.MobilePage{
>
> protected System.Web.UI.MobileControls.TextBox Username; protected
> System.Web.UI.MobileControls.TextBox Password;
>
> protected System.Web.UI.MobileControls.Command CmdLogin; protected
> System.Web.UI.MobileControls.Form formauth;
>
>
>
> private void login_Click(object sender, System.EventArgs e){
>
> String RedirectURL =
> FormsAuthentication.GetRedirectUrl(Username.Text,false);
>
> if (FormsAuthentication.Authenticate(Username.Text,Password.Text))
>
> this.RedirectToMobilePage(RedirectURL);
>
> else
>
> Username.Text="ERROR!!"; }
>
> }
>
>
>
> AND WEB.CONFIG FILE .................
>
> <authentication mode="Forms">
>
> <forms name="CSGMISAuth" path="/" loginUrl="login.aspx"
protection="All"
> timeout="60">
>
> <credentials passwordFormat="Clear">
>
> <user name="user" password="password"> </user>
>
> </credentials>
>
> </forms>
>
> </authentication>
>
> <authorization> <deny users="?" /> </authorization>
>
>
>


(Yan-Hong Huang(MS))

4/9/2002 5:10:00 AM

0

Doug Thews

4/9/2002 6:42:00 AM

0

You need to be using the MobileFormsAuthenticate.RedirectFromLoginPage for
using Forms Authentication on a MIT application. I've found that the
regular ASP.NET forms authentication works sometimes, but it does give me
some random problems.

Here's my code:

Public Class Login
Inherits System.Web.UI.MobileControls.MobilePage
Protected WithEvents Label1 As System.Web.UI.MobileControls.Label
Protected WithEvents txtUserID As System.Web.UI.MobileControls.TextBox
Protected WithEvents Label2 As System.Web.UI.MobileControls.Label
Protected WithEvents frmLogin As System.Web.UI.MobileControls.Form
Protected WithEvents btnLogin As System.Web.UI.MobileControls.Command
Protected WithEvents lblInvalidLogin As
System.Web.UI.MobileControls.Label
Protected WithEvents txtPassword As System.Web.UI.MobileControls.TextBox

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
lblInvalidLogin.Visible = False
End Sub

Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLogin.Click
'Put user code to initialize the page here
Dim objUser As New BookUser()

objUser.Name = txtUserID.Text
objUser.Password = txtPassword.Text
If objUser.Validate Then
Session("CurrentUser") = objUser
Session("UserName") = "Guest"
MobileFormsAuthentication.RedirectFromLoginPage(objUser.Name,
False)
Else
lblInvalidLogin.Visible = True
End If
End Sub

--
Doug Thews
Director, Software Development
D&D Consulting Services


"Murat UCUNCU" <m_ucuncu@hotmail.com> wrote in message
news:eKCgTjz3BHA.2816@tkmsftngp05...
> Hi,
> I have been trying to redirect all mobile page requests to a login page
for
> unauthenticated requests using Forms Authentication. After directed and
> having entered the login information in the login page, I use
> RedirectToLoginPage() method, but,nothing seems to happen. All the data I
> entered in the textbox just disappears but I still remain at the same
login
> page. Is there a way to help me out? Below is the code I used.
>
> Thanks alot
>
> Murat Ucuncu
> --------------------------------------------------------------------------
--
> ----------------------
> LOGIN.ASPX FILE
> public class MobileWebForm1 : System.Web.UI.MobileControls.MobilePage{
>
> protected System.Web.UI.MobileControls.TextBox Username; protected
> System.Web.UI.MobileControls.TextBox Password;
>
> protected System.Web.UI.MobileControls.Command CmdLogin; protected
> System.Web.UI.MobileControls.Form formauth;
>
>
>
> private void login_Click(object sender, System.EventArgs e){
>
> String RedirectURL =
> FormsAuthentication.GetRedirectUrl(Username.Text,false);
>
> if (FormsAuthentication.Authenticate(Username.Text,Password.Text))
>
> this.RedirectToMobilePage(RedirectURL);
>
> else
>
> Username.Text="ERROR!!"; }
>
> }
>
>
>
> AND WEB.CONFIG FILE .................
>
> <authentication mode="Forms">
>
> <forms name="CSGMISAuth" path="/" loginUrl="login.aspx"
protection="All"
> timeout="60">
>
> <credentials passwordFormat="Clear">
>
> <user name="user" password="password"> </user>
>
> </credentials>
>
> </forms>
>
> </authentication>
>
> <authorization> <deny users="?" /> </authorization>
>
>
>