|
 |
aspx thread: SV: Re: The system.web namespace - quick one!
Message #1 by Anders Lundholm <alu@m...> on Wed, 8 Nov 2000 10:58:54 +0100
|
|
Hello Frederik (and thanks for the quick reply).
I'm aware that the previous 'intrinsic' asp objects such as Server,
Request
and Response are available through the context object (to make the life
easier for the aspx developers, I recon). However, I asked the question
because from the documentation, I couldn't actually see how to get the
objects
> If you look at the HttpServerUtility it need to have the
> context of the page as an argument.
> HttpServerUtility(class System.Web.HttpContext context)
I didn't see that from the documentation. Is this because it's still in
pre-beta or what? I thought they'd described the class parameters
properly
in the docs. Let me take a snip from the HttpServerUtility Class docs.
Object
HttpServerUtility
public class HttpServerUtility
This tells me it's not protected, but a public class ready to
instantiate.
Isn't this correct?
> This will work:
> ------
> <% @Page Language=3D"C#" %>
> <%
> Server.Execute("connection.aspx");
> %>
> hello
Well, it doesn't work (perhaps because it only expects .aspx pages -
lets
hope the next beta will support that). It works for .aspx pages but not
for
.asp which is a big problem for me, as I'm building a big oo content
management system (yes, on a beta framework - clever). I'd like to
offer the
.net un-enlightened people access to normal scripting blocks on the
page. I
see no other way to do this but to use the server.execute method.
Any idea to the solution of executing regular asp scripting blocks
without
using the server.execute method? =3D)
<sorry>
So many questions ..
</sorry>
With regards
Anders Lundholm =B7 lundholm@m... =B7 www.mondo.dk
Graphics Design =B7 Web Development =B7 HandCrafted Code (tm)
--
http://www.sphereworx.com [sphere =B7 worx]
Message #2 by "Fredrik Normen" <fredrik.normen@e...> on Wed, 08 Nov 2000 13:32:11 +0100
|
|
> I didn't see that from the documentation. Is this because it's
> still in
> pre-beta or what? I thought they'd described the class parameters
> public class HttpServerUtility
>
> This tells me it's not protected, but a public class ready to
> instantiate.Isn't this correct?
Yes this is right.
I think MS have hide this from the class. Becuase if you use the class
viewer it will not display the HttpSystemUtility constructor.
But if you open System.Web.dll file in ILdasm.exe you will se it.
The HTTPSystemUtitlity class is public but It look like we can't use
the HTTPContext with HTTPSystemUtitlity.
I think this is done that way, because of we should not do something
that can hang the context. I will take a deeper look at this.
>It works for .aspx pages
> but not for
> .asp which is a big problem for me
I think this is becuase the Server.Execute will runt the file you pass
with the .Net runtime engine and it doesn't support .asp
> Any idea to the solution of executing regular asp scripting blocks
> withoutusing the server.execute method? =)
hmm, Maybe you can use the WebRequestFactory classe in the system.net
namespace to execute a .asp page.
Here is an example how you can use the WebRequestFactory.
<%@ Page language="C#" %>
<%@ Assembly Name="System.Net.dll" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<SCRIPT runat="server" LANGUAGE="C#">
public void Page_Load( Object s, EventArgs E )
{
WebRequest req = WebRequestFactory.Create
("http://www.amazon.com");
WebResponse result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
Byte[] read = new Byte[512];
int bytes = ReceiveStream.Read(read, 0, 512);
while (bytes > 0)
{
Response.Write
(System.Text.Encoding.ASCII.GetString(read, 0, bytes));
bytes = ReceiveStream.Read(read, 0, 512);
}
}
</SCRIPT>
/Fredrik Normen
|
|
 |