in my home.aspx page I have a simple login set. when you hit the button it redirects. Here is the code:
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If txtUserID.Text = "" Then
txtUserID.Focus()
Exit Sub
End If
If txtPassword.Text = "" Then
txtPassword.Focus()
Exit Sub
End If
Response.Redirect("UserMain.aspx?userID=" & txtUserID.Text & "&Password=" & txtPassword.Text)
End Sub
Once you hit that button, you get this error message:
Server Error in '/GDCWEB' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
_Default.VarifyUser(String User, String Pass) +171
_Default.Page_Load(Object sender, EventArgs e) +132
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
on my UserMain.aspx page, my page load code is as follows:
Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack = True Then
UserID = Request.QueryString("userID")
Password = Request.QueryString("Password")
VarifyUser(UserID, Password)
End If
End Sub
varify user:
Private Sub VarifyUser(ByVal User As String, ByVal Pass As String)
Dim strSql2 As String
Dim iDr2 As IDataReader
Dim strErr As String
strSql2 = "Select OPER from OPER Where OPER='" & UserID & "'"
If OdbcGetDataReader(cnOper, strSql2, iDr2, strErr) = False Then
lblHello.Text = strErr
btnReturn.Visible = True
iDr2.Close()
Exit Sub
End If
If iDr2.Read = True Then
Dim vUser As String = Trim(iDr2("OPER"))
If UserID = vUser Then
VarifyPass(User, Pass)
End If
Else
lblHello.Text = "Invalid Entry"
btnReturn.Visible = True
Exit Sub
End If
End Sub
varifypass:
Private Sub VarifyPass(ByVal User As String, ByVal Pass As String)
Dim strSql As String
Dim strErr As String
Dim iDr As IDataReader
strSql = "Select PASS from OPER Where OPER='" & User & "'"
If OdbcGetDataReader(cnOper, strSql, iDr, strErr) = False Then
lblHello.Text = strErr
btnReturn.Visible = True
Exit Sub
End If
While iDr.Read
varPass = Trim(iDr("PASS"))
If Pass = varPass Then
lblHello.Text = "Hello, " & User
LoadPage()
Else
lblHello.Text = "Invalid Entry"
btnReturn.Visible = True
End If
Exit While
End While
iDr.Close()
End Sub
All that LoadPage() does is set some buttons to visible=true.
Any idea guys? Thanks!