Friday, March 16, 2012

Object reference not set to an instance of an object.

Hi,
I've developed my first ASP.NET application using VS2005, when I run it from the IDE it works fine but after I deploy it under IIS, it no longer works.

It gives me this error

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:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.Hosting.ISAPIWorkerRequestInProc.GetServerVariable(String name) +1841
System.Web.Hosting.ISAPIWorkerRequest.ReadRequestHeaders() +121
System.Web.Hosting.ISAPIWorkerRequest.GetKnownRequestHeader(Int32 index) +126
System.Web.Hosting.ISAPIWorkerRequestInProc.GetKnownRequestHeader(Int32 index) +104
System.Web.HttpWorkerRequest.HasEntityBody() +17
System.Web.HttpRequest.GetEncodingFromHeaders() +223
System.Web.HttpRequest.get_ContentEncoding() +48
System.Web.HttpRequest.get_QueryStringEncoding() +7
System.Web.HttpRequest.get_QueryStringText() +3379912
System.Web.HttpRequest.get_PathWithQueryString() +10
System.Web.Security.FormsAuthenticationModule.OnEnter(Object source, EventArgs eventArgs) +93
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64



Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

The code to the page that I call looks like:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Login : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{
string fName = "";
string tCode = "";
string sBox = "";


fName = Request.QueryString[1];
tCode = Request.QueryString[0];
sBox = Request.QueryString[2];

string path = "xxxxxxx";

string link = "<a href=\"" + path + sBox + "/";

Session.Add("link", link);
Session.Add("tCode", tCode);

}

}

When I call the page I do pass the parameters in the url?

Thanx in advance

When things seem to work in the built in web server of VS2005 and not in IIS, the problem usually is security in my experience....


Seems like your applications is not configured as an IIS application. Try to create a virtual directory pointing the path of the project and access again~

Thanks
Is there anything(security related) specific I need to configure to make my application work under IIS?

0 comments:

Post a Comment