Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forms method and action

Status
Not open for further replies.

Lladro

Programmer
Mar 5, 2007
18
US
I am having a problem with my form doing a specific action on my form. The code is as follows:

<form id="frmUserLogin" method="post" action="modules.aspx" runat="server" enableviewstate="true">

I need that from this form, once the user has logged in and has been verified as a valid user, to move (action) to the next webpage (modules.aspx).

It is not doing that. The user name and password is verified and correct and it won't move to the next page. What am I doing wrong? Please help!

 
It is not doing that.
What code are you using?

You might want to look into using Server.Transfer or even Response.Redirect depending on what you are actually trying to do?


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
if modules.aspx is in a protected section of your website, and the form on the login page directs to modules.aspx then you have yourself in a loop. here's what's happening

1. user visits login.aspx
2. user enter credentials & submits to modules.aspx
3. credentials sent to modules.aspx
4. modules.aspx authenticates via Identity (currently anonymous) and fails.
5. redirected to login.aspx for validation.

instead have the login.aspx form submit to itself something like this.

Code:
//aspx
<asp:form id="form1" runat="server">
  UserName: <asp:textbox id="UserName" runat="server" />  
  Password: <asp:textbox id="Password" runat="server" TextMode="password" />  
  <asp:Button id="Login" runat="server" text="Log In" OnClick="Login_Click"/>
</asp:form>

//c#
public class Mypage : Page
{
   Protected void Login_Click(object sender, EventArgs e)
   {
      string userName = this.UserName.Text;
      string password = this.Password.Text;

      if ([authenticate user])
      {
          Response.Redirect("modules.aspx");
      }
      else
      {
          //not valie
      }
   }
}
if your using asp.net 2.0 it's even easier with the [tt]<asp:Login />[/tt] control

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
ss-page posting is allowed in the 2.0 framwork, but is not related to the form action tag. This was used in classic ASP. Pages ASP.NET, post back to themselves, then you have to use Server.Transfer or Response.Redirect, as Mark has stated.
 
Thank you jmeckley!

I was able to accomplish something similar to what you sent.

It was very helpful and it is now working properly.

Thanks again!

Lladro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top