本文介绍了'/'应用程序中的asp.net和C#服务器错误.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Server Error in '/' Application.


在登录屏幕中输入用户ID和密码后,出现上述错误.

我正在使用C#,aspnet 4.0框架.


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

I am using C#, aspnet 4.0 framework.

--------
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"/>

推荐答案




这篇关于'/'应用程序中的asp.net和C#服务器错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 05:29
查看更多