Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7670349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:48:09+00:00 2026-05-31T15:48:09+00:00

In my ASP.NET Web Application, the project structure is shown by the following image:

  • 0

In my ASP.NET Web Application, the project structure is shown by the following image:

enter image description here

The Web.config of the Site has form authentication:

<authentication mode="Forms">
  <forms loginUrl="~/Login.aspx" timeout="2880" />      
</authentication>

And the Web.config of the Pages folder has:

<?xml version="1.0"?>
<configuration>
<system.web>
  <authorization>
    <allow roles="Admin"/>
    <deny users="*"/>
  </authorization>
</system.web>

I have an User admin with role Admin. After successful Login I am trying to redirect the user in Home.aspx resides in the Pages folder as:

protected void EMSLogin_Authenticate(object sender, AuthenticateEventArgs e) {
    TextBox UserNameTextBox = EMSLogin.FindControl("UserName") as TextBox;
    TextBox PasswordTextBox = EMSLogin.FindControl("Password") as TextBox;

    if (Membership.ValidateUser(UserNameTextBox.Text, PasswordTextBox.Text)) {
    Response.Redirect("~/Pages/Home.aspx");
    }
}

But it is not working. It is again redirecting to the Login page i.e., Login.aspx with the URL: localhost:3695/Login.aspx?ReturnUrl=%2fPages%2fHome.aspx.

How can I achieve this? Any information will be very helpful.

Regards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:48:10+00:00Added an answer on May 31, 2026 at 3:48 pm

    Membership.ValidateUser only validates the username and password against the membership provider. It doesn’t emit the authentication cookie.

    If you want to do this you need to use the SetAuthCookie method before redirecting:

    if (Membership.ValidateUser(UserNameTextBox.Text, PasswordTextBox.Text)) 
    {
        FormsAuthentication.SetAuthCookie(UserNameTextBox.Text, false);
        Response.Redirect("~/Pages/Home.aspx");
    }
    

    or if in your web.config you set:

    <authentication mode="Forms">
      <forms loginUrl="~/Login.aspx" defaultUrl="~/Pages/Home.aspx" timeout="2880" />
    </authentication>
    

    you could also use the RedirectFromLoginPage method which will emit the authentication cookie and redirect you to the default page:

    if (Membership.ValidateUser(UserNameTextBox.Text, PasswordTextBox.Text)) 
    {
        FormsAuthentication.RedirectFromLoginPage(UserNameTextBox.Text, false);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building my first ASP.Net web application project in VS2010. The site has
Say I have an application with the following structure. // ASP.NET MVC (Web Project)
I'm working on an ASP .NET 2.0 site which uses a Web Application project
I have an ASP.NET application with a <codeSubDirectories> section in web.config. My main project
Good Morning, Has anyone attempted to convert/migrate an ASP.net MVC web application project to
I am working on an asp.net web application project that has around 7 –
We're developing a ASP.Net Web Application project that has a Silverlight 2.0 component. We've
Im using a asp.net 4.0 project. My file structure looks like this RootSite  -Web.Config
I have an ASP.NET web application project which references another project called ModusCore (or
I'm trying to start a new ASP.NET Web Application Project using Visual Studio 2008.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.