'/'应用程序中的asp.net和C#服务器错误. [英] asp.net and C# Server Error in '/' Application.

查看:278
本文介绍了'/'应用程序中的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"/>

推荐答案

我认为您应该检查一下您已经正确设置了网站.此处的信息可能会有所帮助: RedirectFromLoginPage [
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?


您可以在web.config文件中检查连接字符串.
You may check your connection string in web.config file.


由于无效的路径,将引发常见的服务器错误因此,请检查一次.
Commonly server errors will raise because of invalid paths so check it once.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆