473,320 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to set the @Page Async value without an .aspx file?

I have a class file in my App_Code folder called "clsBasePage.vb" that looks
like this:

Public Class clsBasePage
Inherits System.Web.UI.Page
...stuff...
End Class

It's a "page" in that it inherits from ui.page, but has no .aspx file. It's
just a class file.

In creating a new page for my website, say mynewpage.aspx, I remove the
IDE's automatic header & form html so all it contains is this:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="mynewpage.aspx.vb"
Inherits="mynewpage" %>

And I make mynewpage.aspx.vb inherit from clsBasePage, like this:

Partial Class mynewpage
Inherits clsBasePage
...stuff...
End Class

I've recently added this method to clsBasePage

Public Sub GetTheTextFromTheOtherWebsite()

Me.objWebClient = New System.Net.WebClient

With objWebClient
.Headers.Item(Net.HttpRequestHeader.Referer) = "localhost"
.Headers.Item(Net.HttpRequestHeader.UserAgent) = "my web app v1.0"
.BaseAddress = "https://www.theotherwebsite.com"
.DownloadStringAsync(New System.Uri("cgi/server/textmaker.exe",
UriKind.Relative))
End With

End Sub

When I call GetTheTextFromTheOtherWebsite from mynewpage, the
..DownloadStringAsync() method of the WebClient object is throwing this
error:

"Asynchronous operations are not allowed in this context. Page starting an
asynchronous operation has to have the Async attribute set to true and an
asynchronous operation can only be started on a page prior to
PreRenderComplete event."

I believe the typical "fix" for this would be to add the Async="true"
attribute to the @Page directive so that the page can perform an Async task.
Adding this value to mynewpage doesn't change anything, I think I need to
add it to clsBasePage instead. What's got me stumped here is that
clsBasePage doesn't have an .aspx file or a @Page directive at all, so I'm
not sure how to set that Async value to true on my base page class.
Feb 9 '07 #1
1 13191
Have you tried adding the Async="true" attribute as instructed by the
exception message?

<%@ Page Language="VB" Async="true" AutoEventWireup="false"
CodeFile="mynewpage.aspx.vb"
Inherits="mynewpage" %>
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"1388-2/HB" wrote:
I have a class file in my App_Code folder called "clsBasePage.vb" that looks
like this:

Public Class clsBasePage
Inherits System.Web.UI.Page
...stuff...
End Class

It's a "page" in that it inherits from ui.page, but has no .aspx file. It's
just a class file.

In creating a new page for my website, say mynewpage.aspx, I remove the
IDE's automatic header & form html so all it contains is this:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="mynewpage.aspx.vb"
Inherits="mynewpage" %>

And I make mynewpage.aspx.vb inherit from clsBasePage, like this:

Partial Class mynewpage
Inherits clsBasePage
...stuff...
End Class

I've recently added this method to clsBasePage

Public Sub GetTheTextFromTheOtherWebsite()

Me.objWebClient = New System.Net.WebClient

With objWebClient
.Headers.Item(Net.HttpRequestHeader.Referer) = "localhost"
.Headers.Item(Net.HttpRequestHeader.UserAgent) = "my web app v1.0"
.BaseAddress = "https://www.theotherwebsite.com"
.DownloadStringAsync(New System.Uri("cgi/server/textmaker.exe",
UriKind.Relative))
End With

End Sub

When I call GetTheTextFromTheOtherWebsite from mynewpage, the
..DownloadStringAsync() method of the WebClient object is throwing this
error:

"Asynchronous operations are not allowed in this context. Page starting an
asynchronous operation has to have the Async attribute set to true and an
asynchronous operation can only be started on a page prior to
PreRenderComplete event."

I believe the typical "fix" for this would be to add the Async="true"
attribute to the @Page directive so that the page can perform an Async task.
Adding this value to mynewpage doesn't change anything, I think I need to
add it to clsBasePage instead. What's got me stumped here is that
clsBasePage doesn't have an .aspx file or a @Page directive at all, so I'm
not sure how to set that Async value to true on my base page class.
Feb 10 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: vMike | last post by:
I have an imageurl of an image (a larger image) set to an aspx file which does a Response.OutputStream. The url includes a query string. When the page is loaded this aspx file for this large image...
1
by: Jerry Tovar | last post by:
I am using .Net 2003 on a XPPro running IIS. I am unable to view any of my ASPX webforms in a browser unless I modify the .ASPX file and replace Codebehind="employee.aspx.cs" with...
1
by: rinkal brahmbhatt | last post by:
what if i delete an aspx file from my project if i had compiled the project once....will that project run without any error.....or will i need the aspx file after compilation *** Sent via...
4
by: TWEB | last post by:
I think I may have an IIS / ASP.Net Configuration issue that I need some guidance with resolving. Here's the problem: a) I have a .stm file. b) I referenc a .aspx file on this .stm file using a...
5
by: c676228 | last post by:
Hi, I guess I am confused. In aspx script, I mean (you won't use Codebehind="enrollinfo.aspx.vb", but mix code with html and code together) You can access user control's property directly. Since I...
4
by: Neil.Smith | last post by:
I can't seem to find any references to this, but here goes: In there anyway to parse an html/aspx file within an asp.net application to gather a collection of controls in the file. For instance...
13
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains...
16
by: flip2flik | last post by:
Hi. I am using visual web developer express edition and I am using vb.net as the programming language. I want to create a new aspx file on a button click. I will have a template that the new...
0
by: Moe Sisko | last post by:
Using dotnet 2.0. Say I have a user control like the following : public partial class Controls_MyControl : System.Web.UI.UserControl { public enum SomeBitFlag { OptionA = 0x01, OptionB =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.