Object reference not set to an instance of an object

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.
 
C

Chris Taylor

Hi,

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

Hope this helps

Chris Taylor
 
T

Tascien

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top