how do you read the URI in ASP.Net (vb)?

D

Dave

Hi all,

How do you read in the URI (or URL) in ASP.Net in a VB code-behind page?
I tried several things that looked like they should work including the
following:

Dim XXX as String =
HttpContext.Current.Request.UrlReferrer.AbsolutePath.ToString
or
Dim XXX as String = Request.UrlReferrer.AbsolutePath.ToString
or
Dim XXX as String = Request.UrlReferrer.AbsolutePath

and plopped this in a Page_Load() sub (all other statements were commented
out)

but it generates the following 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.


Here is the full page code behind in VB:

Public Class _default1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim xxx As String =
HttpContext.Current.Request.UrlReferrer.AbsolutePath.ToString

End Sub

End Class


I know how to do this in classic ASP no problem, but would like to do this
the preferred method.
TIA

Dave
 

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