473,713 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Response.Redire ct problem in ASP.NET (object refrence not set...)

11 New Member
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.EventArg s) Handles btnLogin.Click
If txtUserID.Text = "" Then
txtUserID.Focus ()
Exit Sub
End If
If txtPassword.Tex t = "" Then
txtPassword.Foc us()
Exit Sub
End If
Response.Redire ct("UserMain.as px?userID=" & txtUserID.Text & "&Password= " & txtPassword.Tex t)
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.NullRefe renceException: 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" %>


2) Add the following section to the configuration file of your application:

<configuratio n>
<compilation debug="true"/>

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:

[NullReferenceEx ception: Object reference not set to an instance of an object.]
_Default.Varify User(String User, String Pass) +171
_Default.Page_L oad(Object sender, EventArgs e) +132
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +99
System.Web.UI.C ontrol.LoadRecu rsive() +47
System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +1061

Version Information: Microsoft .NET Framework Version:2.0.507 27.42; ASP.NET Version:2.0.507 27.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.EventArg s) Handles Me.Load
If Not Page.IsPostBack = True Then
UserID = Request.QuerySt ring("userID")
Password = Request.QuerySt ring("Password" )
VarifyUser(User ID, Password)
End If
End Sub

varify user:

Private Sub VarifyUser(ByVa l 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 OdbcGetDataRead er(cnOper, strSql2, iDr2, strErr) = False Then
lblHello.Text = strErr
btnReturn.Visib le = True
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
lblHello.Text = "Invalid Entry"
btnReturn.Visib le = True
Exit Sub
End If

End Sub


Private Sub VarifyPass(ByVa l 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 OdbcGetDataRead er(cnOper, strSql, iDr, strErr) = False Then
lblHello.Text = strErr
btnReturn.Visib le = True
Exit Sub
End If

While iDr.Read
varPass = Trim(iDr("PASS" ))
If Pass = varPass Then
lblHello.Text = "Hello, " & User
lblHello.Text = "Invalid Entry"
btnReturn.Visib le = True
End If
Exit While
End While
End Sub

All that LoadPage() does is set some buttons to visible=true.

Any idea guys? Thanks!
Jun 9 '06 #1
3 8091
11 New Member
After playing around with it even more, it seems that its an authentication problem. It runs fine and connects to the database when run via a compile within VS 2005, but when run off our server, it doesnt want to connect, therefore causing the above error. Any ideas?
Jun 9 '06 #2
11 New Member
I'm also using a DSN for the connection string to the database. It works when running from a compile and off the local port, but doesnt work when on our webserver.
Jun 9 '06 #3
11 New Member
I now think it could be because in my code I don't put in a default value for my IDataReaders. I get the warning at the bottom of the screen

Variable 'iDr' is passed by reference before it has been assigned a value. A null reference exception could result at runtime.

And thats exactly what its doing. What default variable can I have it set to so that it wont actually run.
Jun 9 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Stephen | last post by:
I was wondering if someone can help me with an web application design problem. I have a aspx page which builds up an arraylist called addresses and outputs the values in the arraylist items to a datagrid. I am using the viewstate object to store the Arraylist items on the page on postback. My PROBLEM is that I need to redirect the user to a new aspx page and on this new page i need to be able to access the items in my arraylist. Is this...
by: Max Dupenois | last post by:
I've seen numerous articles with similair (similar sp?) titles to this in my search.. unfortunately none of them seem to contain what i want, (or if they do i need someone to point out my stupidity for me :p ) Anyway I have a file dialog box being opened using Response.AddHeader "Content-Disposition", "attachment;filename=""" & displayName & """" Response.ContentType = "application/binary"
by: Anne | last post by:
hie there, i want to be able to pass multiple parameters to another page. currently, i am able to do so, but somehow i feel it is not the correct way to do it. below is part of what i have so far. 'first page Private Sub btnOK_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click Response.Redirect("InputValues.aspx?Requestor=" &
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx serves two purposes, 1. it contains a tab strip with response.redirects to navigate to the other pages; 2. I authenticate the user by check to see if a cookie exists, if it doesn't I redirect to a login screen.
by: joseph pattom | last post by:
Hi all i am using <customErrors mode="On" defaultRedirect="ErrorDisplay.aspx"/> in my web.config file and getting redirected to "ErrorDisplay.aspx" in almost all the unhandled exceptions but in case of certain errors its not getting redirected (especialy Acces Violations(object refrence to null exception)). if eny body know the solution pls do reply thx in advance
by: Niggy | last post by:
I get an error - any help appreciated. System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End() at System.Web.HttpResponse.Redirect(String url, Boolean endResponse) at WebApplication1.WebForm4.DropDownList1_SelectedIndexChanged(Object sender, EventArgs e) in...
by: KBuser | last post by:
I recently developed an internal website with various queries against our SQL server. I added buttons with Response.Redirect. These buttons do not work with Internet Explorer, however when using Firefox the page works flawless. Does anyone know why this is happening or how to fix it?
by: mike.biang | last post by:
I have an ASP page that is using an XMLHTTP object to request various pages from my server. I keep a single session throughout the XMLHTTP requests by bassing the ASPSESSIONID cookie through the XMLHTTP object. However, when the page requested through the XML object makes a <%Response.Redirect()%> call, a new session is created each time. Is this a flaw in the XMLHTTP Object? How can I force the session to remain the same after a...
by: gigi | last post by:
How to send more than one value using response redirect? For example i can send one like this response.Redirect "pregled.asp?ime=" & strUserName but how to send two or more values? I tried response.Redirect("pregled.asp?ime=" & strUserName & " & prezime = " & strUserLastName) but it didn't work.
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.