Meaning of "Post a Page to a Page"

R

Robert Cramer

What does it mean - literally - to "post" a page? I understand that we have
the HTTP protocol and it's POST operation going on behind the scenes... but
I'm wanting to know what it means to "post a page to a page" -- specifically
in terms of what ASP.NET does with the HTTP POST.

To help clarify the understanding I am lacking and asking for here... I once
wrote an HTTP server using the Win32 API and it would sit there and listen
for HTTP POSTs on a specific port and respond accordingly. So I know that
nuts-n-bolts level of activity. But what I'm unclear on is what is going on
with ASP.NET. I suppose IIS is what is analogous to my HTTP listener... and
IIS is listening to port 80 (by default) and then, depending on the
requested resource, passes off the request to ASP.NET - and down the
pipeline it goes. And that is exactly where I get lost. What does ASP.NET do
to "post a page to a page"?

With ASP.NET, we have these concepts:

--- "postback" (ala .IsPostBack)

--- we have the idea of "posting a page to another page"

I understand that with the HTTP Post, some data is received by ASP.NET -
including an aspx page name. What is done with that page name at the end of
the point in the ASP.NET pipeline where something is done with that page
name? What is that something? Is it simply that ASP.NET runs any code-behind
logic of the requested page and sends it back down to the browser? Is it
anything more than that? And how does ASP.NET how to correctly set the value
of .IsPostBack?

Thanks.
 
J

Juan T. Llibre

re:
!> how does ASP.NET how to correctly set the value of .IsPostBack?

public bool get_IsPostBack();
Declaring Type: System.Web.UI.Page

public bool get_IsPostBack()
{
if (this._requestValueCollection == null)
{
return false;
}
return !this._fPageLayoutChanged;
}

public bool IsPostBack { get; }

[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool IsPostBack
{
get
{
if (this._requestValueCollection == null)
{
return false;
}
return !this._fPageLayoutChanged;
}
}

In other words, it checks to see if the RequestValueCollection is null.
If it is null, it's not a postback; if it's not, it is a postback.

What I would suggest is for you is to get yourself
a free copy of Lutz Roeder's Reflector for .Net :

http://www.aisto.com/roeder/dotnet/

....and use it to see which classes compose, not only the Postback handler,
but also any other handler you wish to figure out how it works.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
S

Scott Roberts

What does it mean - literally - to "post" a page?

I think it means exactly what you think it means. An HTTP POST is sent to
the server.
I understand that we have the HTTP protocol and it's POST operation going
on behind the scenes... but I'm wanting to know what it means to "post a
page to a page" -- specifically in terms of what ASP.NET does with the
HTTP POST.

To help clarify the understanding I am lacking and asking for here... I
once wrote an HTTP server using the Win32 API and it would sit there and
listen for HTTP POSTs on a specific port and respond accordingly. So I
know that nuts-n-bolts level of activity. But what I'm unclear on is what
is going on with ASP.NET. I suppose IIS is what is analogous to my HTTP
listener... and IIS is listening to port 80 (by default) and then,
depending on the requested resource, passes off the request to ASP.NET -
and down the pipeline it goes. And that is exactly where I get lost. What
does ASP.NET do to "post a page to a page"?

With ASP.NET, we have these concepts:

--- "postback" (ala .IsPostBack)

--- we have the idea of "posting a page to another page"

I'm not exactly certain what you mean by "posting a page to another page".
Are you referring to cross-page postbacks? Those are fairly uncommon, at
least in my experience.
I understand that with the HTTP Post, some data is received by ASP.NET -
including an aspx page name. What is done with that page name at the end
of the point in the ASP.NET pipeline where something is done with that
page name?

Well, I think the answer to that question is quite lengthy. The short answer
is the one you apparently already know - it runs the "code" (both
declarative and procedural) of the aspx page. The "code" produces HTML which
is sent back to the browser.
What is that something? Is it simply that ASP.NET runs any code-behind
logic of the requested page and sends it back down to the browser? Is it
anything more than that? And how does ASP.NET how to correctly set the
value of .IsPostBack?

I'm not actually 100% certain, but I've always assumed that it looks at the
VIEWSTATE (received as part of the HTTP POST).
 
B

bruce barker

its just like your server. iis looks at the extension (mappings) and when its
aspx, it pipes the request (or post) to the asp.net runetime. the runtime
send the response back to iis.

in the standard asp.net page request it does the following

1) parse the input request into a form, quesrystring and files collections
(looks at mime type to do this).

2) determines which aspx page to call. creates an instance of the page class
and runs the page life cycle events.

IsPostback is just a test if the hidden field "__viewstate" is in the forms
collection.

-- bruce (sqlwork.com)


-- bruce (sqlwork.com)
 
J

Juan T. Llibre

re:
!> I've always assumed that it looks at the VIEWSTATE (received as part of the HTTP POST)

What it looks for is whether there's an incoming stream.

public sealed class HttpPostedFile
{
// Fields
private string _contentType;
private string _filename;
private HttpInputStream _stream;

// Methods
internal HttpPostedFile(string filename, string contentType, HttpInputStream stream)
{
this._filename = filename;
this._contentType = contentType;
this._stream = stream;
}

public void SaveAs(string filename)
{
FileStream stream = new FileStream(filename, FileMode.Create);
try
{
if (this._stream.DataLength > 0)
{
stream.Write(this._stream.Data, this._stream.DataOffset, this._stream.DataLength);
}
stream.Flush();
}
finally
{
stream.Close();
}
}

// Properties
public int ContentLength
{
get
{
return this._stream.DataLength;
}
}

public string ContentType
{
get
{
return this._contentType;
}
}

public string FileName
{
get
{
return this._filename;
}
}

public Stream InputStream
{
get
{
return this._stream;
}
}
}




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 

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