Request not available

D

David C

I have an aspx page that contains an iframe where I point to another aspx
page. In the aspx page that is in the iframe, I have VB code as follows:

<script language="vb" runat="server">

Dim strFolder As String = Request.QueryString("fldr").ToString

Dim PathVar As String = Server.MapPath("/wafgo/Pictures") & "\" & strFolder
& "\"

</script>

The Request.Querystring line is failing with the error Request is not
available in this context

I'm trying to pass the page a folder path and I don't know how else to do
it. I'm open to ideas. Thanks.

David
 
T

Teemu Keiski

Hi,

the code should be in any event of the Page. Like Init, Load or something.
Otherwise it gets executed "too early" during page lifecycle when certain
thuings aren't associated with the page, yet

Try

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles
MyBase.Load

Dim strFolder As String = Request.QueryString("fldr").ToString
....
End Sub
 
D

David C

Should I have it in the called page or in the page referred to in the
iframe? Thanks.

David
 
G

George Ter-Saakov

This code
Dim strFolder As String = Request.QueryString("fldr").ToString
is executed during construction phase.

ASP.NET page did not get a chance to assign Request to the page.



George.
 
B

bruce barker

request is a Page property, which can not be accessed by a class field
initialization expression, because the constructor has not been called.

class foo
dim strFolder as string = myProperty
...

try:

Dim strFolder As String =
HttpContext.Current.Request.QueryString("fldr").ToString

-- bruce (sqlwork.com)
 

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

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,197
Latest member
Sean29G025

Latest Threads

Top