Object reference not set to an instance of an object

  • Thread starter Thread starter Tascien
  • Start date Start date
T

Tascien

What's wrong with this code?

it would work perfect in vb. VB.net seem to be filled with error triggers...

<script language="VB" runat="server" src="/scripts/main_lib.vb"></script>
<script language="VB" runat="server">
Public PollMode As string = "vote"
' ***** the code below fails as object reference not set!
Public urlRedirect As String = Request.ServerVariables("SCRIPT_NAME")
</script>

Please help.
 
Hi,

Try using
HttpContext.Current.Request.ServerVariables("SCRIPT_NAME")

Hope this helps

Chris Taylor
 
Thank you.

That works,

but, why do we have to write more codes than we used to write in vb?

Is this to make the language better? I wonder if vb.net will have
better adoption than vb was...

Not criticizing vb.net, just want to know why we would be wanting to
write more code than we used to.
 
Back
Top