无法重定向页面 [英] cant redirecting page
本文介绍了无法重定向页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我们将值传递给它时我创建了登录页面并没有重定向到主页
它在执行时会产生任何错误....我正在使用vb。
i不知道我的代码出了什么问题..
plz帮帮我..
提前感谢..
这是我登录页面的代码。登录按钮点击事件。
i have created login page when we pass the value to it doesnt redirect to home page
it doent generates any error while executing .... i m using vb .
i dont knw what going wrong wid my code..
plz help me..
thanks in advance..
here is my code for login page . it is on login button click event.
Dim cn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Welcome\Documents\Visual Studio 2010\Projects\fc\App_Data\fc.mdf;Integrated Security=True;User Instance=True")
Dim str As String
str = "select count(*) from r_user where eml='" & eml_txt.Text & "' and pwd='" & pwd_txt.Text & "'"
Dim cmd As New SqlCommand(str, cn)
cn.Open()
cmd.ExecuteScalar()
Session("eml") = eml_txt.Text
If (eml_txt.Text = "admin" And pwd_txt.Text = "admin") Then
Response.Redirect("admin.aspx")
Else
str = "select * from r_user where eml='" & Session("eml") & "'"
Dim da As New SqlDataAdapter(str, cn)
Dim dt As New DataTable
Dim s = da.Fill(dt)
If (s < 1) Then
Response.Redirect("profile.aspx")
Else
Response.Redirect("login.aspx")
End If
cn.Close()
End If
推荐答案
试试这个,这可能会有所帮助
Try this, This may help
HttpContext.Current.Response.Redirect("login.aspx", false);
cmd.ExecuteScalar()
这是用于更新数据库表而不要求任何信息回来
你必须创建一个读取器对象,它将读取响应返回,并将命令对象提供给阅读器。
That''s for updating a database table without asking for any information back
You have to create a reader object, that will read the response back, and feed your command object into the reader.
myConnection.Open()
Dim myReader As SqlDataReader = myCommand.ExecuteReader()
Dim FieldCount As Integer = myReader.FieldCount
While myReader.Read()
m_count = myReader.GetString(0)
End While
if (m_Count > 0) then
httpcontext.current.response.redirect("home.aspx")
end if
这篇关于无法重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文