页面未重定向C#ASP.net

页面未重定向C#ASP.net,c#,asp.net,response.redirect,C#,Asp.net,Response.redirect,为什么我的页面没有重定向?弹出“有效用户”提示。但是我的页面没有重定向。问题是什么 protected void LoginButton_Click1(object sender, EventArgs e) { if (Page.IsValid) { User userLogin = new User(); userLogin.userId = this.txtUserName.Text.Trim(); userLogin.userPwd = this.txtPwd.Text.Trim();

为什么我的页面没有重定向?弹出“有效用户”提示。但是我的页面没有重定向。问题是什么

protected void LoginButton_Click1(object sender, EventArgs e)
{
if (Page.IsValid)
{
User userLogin = new User();
userLogin.userId = this.txtUserName.Text.Trim();
userLogin.userPwd = this.txtPwd.Text.Trim();

string result = CommonFunctions.Check_ValidUser(userLogin);

if (result == "s")
{
Response.Write("<script>alert('" + "Valid user"+ "') ; location.href='Login.aspx'</script>");
Response.Redirect("DrugEntry.aspx",true);
}
else
{
string message = "We don't seem to have this user registered. Please try again.";
Response.Write("<script>alert('" + message + "') ; 
location.href='Login.aspx'</script>");
}
}
}
受保护的无效登录按钮\u单击1(对象发送者,事件参数e)
{
如果(第页有效)
{
用户userLogin=新用户();
userLogin.userId=this.txtUserName.Text.Trim();
userLogin.userPwd=this.txtPwd.Text.Trim();
字符串结果=CommonFunctions。检查有效性(userLogin);
如果(结果=“s”)
{
Response.Write(“警报”(“+”有效用户“+”);location.href='Login.aspx');
重定向(“DrugEntry.aspx”,true);
}
其他的
{
string message=“我们似乎没有注册此用户。请重试。”;
响应。写入(“警报(“+”消息+”);
location.href='Login.aspx');
}
}
}

您的代码似乎是正确的

确保您的页面位于同一目录中。如果它不在使用它的同一目录中,如以下示例所述:

Response.Redirect("[Directory Name]/DrugEntry.aspx",true);

您是否尝试通过在该行放置断点进行调试?您的页面是否存在于正确的位置?您的“DrugEntry.aspx”页面是否位于同一目录或文件夹中?@shree.pat18我确实是这样做的。它执行该行。但不重定向。如果用户未注册,警报是否有效?您正在构造一个包含倒逗号的字符串,然后将该字符串传递给javascript警报。可能是试图指示目录名应该放在哪里。@Bharadwaj[目录名]表示页面所在的[文件夹名]