Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Redirect with POST ?

Reply
Thread Tools

Redirect with POST ?

 
 
Savanah
Guest
Posts: n/a
 
      02-07-2006
Hello,

I would like to call another page using POST method, something like this :

Response.Redirect("http://www.mydomain.com/cgi-bin/log.dll?email="+tbLoginID").

I set this in my page
<form id="form1" method="post" runat="server

But it's doen't work...

ASP.NET cannot call any page n POST method ?
Anyone can help me, thank in advance.

Regards,
Savanah


 
Reply With Quote
 
 
 
 
Peter Rilling
Guest
Posts: n/a
 
      02-07-2006
No. The server has nothing to do with posting. The client is the one that
packages the headers and sends the post. Using Redirect is nothing more
that if the user had typed that URL in themselves.

You can play tricks by sending the page contents down with the form fields
filled in, then using JavaScript do a submit immediately.

By the way, when you call Redirect, none of the page contents actually is
sent to the browser. The control mechanism for redirecting is a single
header field and so ASP.NET knows that there is no point in sending down any
other content.

"Savanah" <(E-Mail Removed)> wrote in message
news:43e90b0f$0$290$(E-Mail Removed)...
> Hello,
>
> I would like to call another page using POST method, something like this :
>
> Response.Redirect("http://www.mydomain.com/cgi-bin/log.dll?email="+tbLoginID").
>
> I set this in my page
> <form id="form1" method="post" runat="server
>
> But it's doen't work...
>
> ASP.NET cannot call any page n POST method ?
> Anyone can help me, thank in advance.
>
> Regards,
> Savanah
>



 
Reply With Quote
 
 
 
 
Savanah
Guest
Posts: n/a
 
      02-07-2006
Thank you for your reply.

I try to use Server.Transfer but don't work too

How I can send URL using POST method ?

"Peter Rilling" <(E-Mail Removed)> a écrit dans le message de news:
http://www.velocityreviews.com/forums/(E-Mail Removed)...
> No. The server has nothing to do with posting. The client is the one
> that packages the headers and sends the post. Using Redirect is nothing
> more that if the user had typed that URL in themselves.
>
> You can play tricks by sending the page contents down with the form fields
> filled in, then using JavaScript do a submit immediately.
>
> By the way, when you call Redirect, none of the page contents actually is
> sent to the browser. The control mechanism for redirecting is a single
> header field and so ASP.NET knows that there is no point in sending down
> any other content.
>
> "Savanah" <(E-Mail Removed)> wrote in message
> news:43e90b0f$0$290$(E-Mail Removed)...
>> Hello,
>>
>> I would like to call another page using POST method, something like this
>> :
>>
>> Response.Redirect("http://www.mydomain.com/cgi-bin/log.dll?email="+tbLoginID").
>>
>> I set this in my page
>> <form id="form1" method="post" runat="server
>>
>> But it's doen't work...
>>
>> ASP.NET cannot call any page n POST method ?
>> Anyone can help me, thank in advance.
>>
>> Regards,
>> Savanah
>>

>
>



 
Reply With Quote
 
Joerg Jooss
Guest
Posts: n/a
 
      02-07-2006
Thus wrote Peter,

> No. The server has nothing to do with posting. The client is the one
> that packages the headers and sends the post. Using Redirect is
> nothing more that if the user had typed that URL in themselves.


That's probably popular belief, but not true.

HTTP defines status code 307 (Temporary Redirect) to redirect a POST as POST.
The run-of-the-mill redirect everybody knows OTOH is 302
(Found), which is what you get if you call HttpResponse.Redirect(). To make
a sad story short, a 302 blindly turns POST into GET (first it was bug, today
it's a feature).

But it's not hard to implement a 307 redirect in ASP.NET:

public void RedirectTemporary(string url) {
Response.ClearContent();
Response.StatusCode = 307;
Response.StatusDescription = "Temporary Redirect";
Response.RedirectLocation = ResolveClientUrl(url); // this assumes url
is relative, like "~/PathTo/WebForm.aspx"
Response.Flush();
}

Note: According to the HTTP 1.1 spec, a browser should warn the user before
redirecting a POST request. Firefox follows the spec, IE6 doesn't.

Cheers,
--
Joerg Jooss
(E-Mail Removed)


 
Reply With Quote
 
Peter Rilling
Guest
Posts: n/a
 
      02-07-2006
I learned something, cool.

"Joerg Jooss" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) .com...
> Thus wrote Peter,
>
>> No. The server has nothing to do with posting. The client is the one
>> that packages the headers and sends the post. Using Redirect is
>> nothing more that if the user had typed that URL in themselves.

>
> That's probably popular belief, but not true.
> HTTP defines status code 307 (Temporary Redirect) to redirect a POST as
> POST. The run-of-the-mill redirect everybody knows OTOH is 302 (Found),
> which is what you get if you call HttpResponse.Redirect(). To make a sad
> story short, a 302 blindly turns POST into GET (first it was bug, today
> it's a feature).
>
> But it's not hard to implement a 307 redirect in ASP.NET:
>
> public void RedirectTemporary(string url) {
> Response.ClearContent();
> Response.StatusCode = 307;
> Response.StatusDescription = "Temporary Redirect";
> Response.RedirectLocation = ResolveClientUrl(url); // this assumes url is
> relative, like "~/PathTo/WebForm.aspx"
> Response.Flush();
> }
>
> Note: According to the HTTP 1.1 spec, a browser should warn the user
> before redirecting a POST request. Firefox follows the spec, IE6 doesn't.
>
> Cheers,
> --
> Joerg Jooss
> (E-Mail Removed)
>
>



 
Reply With Quote
 
Joerg Jooss
Guest
Posts: n/a
 
      02-07-2006
Thus wrote Peter,

> I learned something, cool.


You're welcome

I just wish the ASP.NET product team would include this as another HttpResponse.Redirect()
overload:

HttpResponse.Redirect(string url, bool endResponse, HttpRedirectStatus status)

Cheers,
--
Joerg Jooss
(E-Mail Removed)


 
Reply With Quote
 
Joerg Jooss
Guest
Posts: n/a
 
      02-08-2006
Thus wrote Joerg,

> But it's not hard to implement a 307 redirect in ASP.NET:
>
> public void RedirectTemporary(string url) {
> Response.ClearContent();
> Response.StatusCode = 307;
> Response.StatusDescription = "Temporary Redirect";
> Response.RedirectLocation = ResolveClientUrl(url); // this assumes
> url
> is relative, like "~/PathTo/WebForm.aspx"
> Response.Flush();
> }


Important note: The receiving web form must apply the directive EnableViewStateMac="false",
otherwise Machine Authentication Check blows up in your face.

Cheers,
--
Joerg Jooss
(E-Mail Removed)


 
Reply With Quote
 
Savanah
Guest
Posts: n/a
 
      02-08-2006
Thank you Joerg Joos.

But you method don't work with .NET v1.1, I got error on ResolveClientUrl
function

I'm trying to use Server.Transfer like this :

Server.Transfer("http://localhost/cgi-bin/webengine.dll/log?email="+tbMail.Text+"&pw="+tbPassword.Text");
// Server redirection

I got error message :
"Error executing child request for
"http://localhost/cgi-bin/webengine.dll/log?email="+tbMail.Text+"&pw="+tbPassword.Text"

Why ? I can access at this page when copy and paste URL into IE ...

Regards,
Savanah


"Joerg Jooss" <(E-Mail Removed)> a écrit dans le message de news:
(E-Mail Removed)...
> Thus wrote Joerg,
>
>> But it's not hard to implement a 307 redirect in ASP.NET:
>>
>> public void RedirectTemporary(string url) {
>> Response.ClearContent();
>> Response.StatusCode = 307;
>> Response.StatusDescription = "Temporary Redirect";
>> Response.RedirectLocation = ResolveClientUrl(url); // this assumes
>> url
>> is relative, like "~/PathTo/WebForm.aspx"
>> Response.Flush();
>> }

>
> Important note: The receiving web form must apply the directive
> EnableViewStateMac="false", otherwise Machine Authentication Check blows
> up in your face.
>
> Cheers,
> --
> Joerg Jooss
> (E-Mail Removed)
>
>



 
Reply With Quote
 
Joerg Jooss
Guest
Posts: n/a
 
      02-09-2006
Thus wrote Savanah,

> Thank you Joerg Joos.
>
> But you method don't work with .NET v1.1, I got error on
> ResolveClientUrl function


Yes, this a .NET 2.0 API.

> I'm trying to use Server.Transfer like this :
>
> Server.Transfer("http://localhost/cgi-bin/webengine.dll/log?email="+tb
> Mail.Text+"&pw="+tbPassword.Text");
>
> // Server redirection
>
> I got error message :
> "Error executing child request for
> "http://localhost/cgi-bin/webengine.dll/log?email="+tbMail.Text+"&pw="
> +tbPassword.Text"
> Why ? I can access at this page when copy and paste URL into IE ...


That cannot work. HttpServerUtility.Transfer() only works within an ASP.NET
application, and has *nothing* to do with HTTP redirects. If you cannot use
ResolveClientUrl(), just remove the call and use absolute URLs with the method
I presented.

Cheers,
--
Joerg Jooss
(E-Mail Removed)


 
Reply With Quote
 
Savanah
Guest
Posts: n/a
 
      02-10-2006
so ASP.NET is unable to make simple page redirection using Post method ?!!



"Joerg Jooss" <(E-Mail Removed)> a écrit dans le message de news:
(E-Mail Removed)...
> Thus wrote Savanah,
>
>> Thank you Joerg Joos.
>>
>> But you method don't work with .NET v1.1, I got error on
>> ResolveClientUrl function

>
> Yes, this a .NET 2.0 API.
>> I'm trying to use Server.Transfer like this :
>>
>> Server.Transfer("http://localhost/cgi-bin/webengine.dll/log?email="+tb
>> Mail.Text+"&pw="+tbPassword.Text");
>>
>> // Server redirection
>>
>> I got error message :
>> "Error executing child request for
>> "http://localhost/cgi-bin/webengine.dll/log?email="+tbMail.Text+"&pw="
>> +tbPassword.Text"
>> Why ? I can access at this page when copy and paste URL into IE ...

>
> That cannot work. HttpServerUtility.Transfer() only works within an
> ASP.NET application, and has *nothing* to do with HTTP redirects. If you
> cannot use ResolveClientUrl(), just remove the call and use absolute URLs
> with the method I presented.
>
> Cheers,
> --
> Joerg Jooss
> (E-Mail Removed)
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Response.redirect does not redirect from .aspx page =?Utf-8?B?VHJveQ==?= ASP .Net 3 10-15-2008 09:07 PM
Redirect to secure FTP site via response.redirect Ron Howard ASP General 2 08-11-2004 07:40 PM
Basic Q - Response.Redirect, all redirect to first Response.Redirect statement Sal ASP .Net Web Controls 1 05-15-2004 03:46 PM
Post post post. Shel-hed Computer Support 2 11-08-2003 07:41 AM
LWP::UserAgent to POST and redirect browser at the same time La Jesus Perl 9 10-27-2003 09:55 PM



Advertisments