Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Server Error in '/' Application.

After I enter user id and password in login screen, I get above error.

I am using C#, aspnet 4.0 framework.

C#
--------
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security; 
namespace WebApplication9
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        { if (FormsAuthentication.Authenticate(txtUsername.Text, txtPassword.Text)) 
        { lblStatus.Text = ("Welcome " + txtUsername.Text); FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, true); 
        } 
        else
        { lblStatus.Text = "Invalid login!"; }
        } 
    }
}
----------------- form
<head  runat="server">
    <title></title>
</head>
<body>
    <form id="form1"  runat="server">
    
        Username: <asp:TextBox ID="txtUsername" runat="server" /><br> 
        Password: <asp:TextBox ID="txtPassword" runat="server" /><br> 
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Login" /><br>
        <asp:Label ID="lblStatus" runat="server" Text="Please login">
    </form>
</body>
</html>
------------  webconfig
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->   
      
        <forms name="TestAuthCookie" loginUrl="~/WebForm1.aspx" timeout="30">
          
            
            
          
        </forms>
      
      
        
      
      
      <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
Posted
Updated 15-Nov-12 21:10pm
v3
Comments
Mohamed Mitwalli 8-Nov-12 2:42am    
Check your connectionstring
You have to give more information...
May be codes of Login page...
ketfos1 8-Nov-12 8:59am    
-- removed by digimanus and set in question

I think you should check to see that you have properly setup your site. The information here might help: RedirectFromLoginPage[^].

Is an error being generated? What page are you starting from?
 
Share this answer
 
You may check your connection string in web.config file.
 
Share this answer
 
Commonly server errors will raise because of invalid paths so check it once.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900