473,386 Members | 1,647 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,386 software developers and data experts.

ASP .NET redirect with POST data

21
Is it possible to redirect to a web page while sending data using POST method at the same time in ASP .NET?

I know that we can do it using GET method easily by doing Response.Redirect(URL + params) but is it possible to do redirection like that while sending data via POST method to that new page? Thanks.
Nov 22 '07 #1
7 25842
dip_developer
648 Expert 512MB
Is it possible to redirect to a web page while sending data using POST method at the same time in ASP .NET?

I know that we can do it using GET method easily by doing Response.Redirect(URL + params) but is it possible to do redirection like that while sending data via POST method to that new page? Thanks.
why do you need this..??? As far i know you cannot......if you have some problem relating the query string parameters which is seen in the browser's address bar which you dont want then let us know......there are plenty of ways.........
Nov 22 '07 #2
bakpao
21
I want to pass very long parameters to the new page, which is longer than the max size of URL. They are done across different web sites, so I can't put it in a database first or any other storage locations.
Nov 22 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
Hi,
Does using session solve your problem?

Since POST method cannot be used, then you would have to look at other options
Nov 22 '07 #4
bakpao
21
Thanks for the help but I can't use session because they are across different websites so session won't work.

However I figured out a trick to solve this. :)

Basically I just created a form and fills the fields with the data I wanted to post. E.g.

Expand|Select|Wrap|Line Numbers
  1. <form id="letsplay" action="http://somewebsite.com/somepage.asp" method=post>
  2.     <input name="story" type="text" value="<% =story %>"></input>
  3.     <input type="submit" />
  4. </form>
  5.  
Then I added this simple script:

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript">
  2.     document.forms[1].submit();
  3. </script>
  4.  
Effectively it will post the data for me as a post to the target URL when I open the page. It's not perfect (e.g. it won't work if the user disables the Javascript) but it's good enough!
Nov 22 '07 #5
Murdz
34
Hi,
Does using session solve your problem?

Since POST method cannot be used, then you would have to look at other options
Server.Transfer should work for you if it's within the same website application.
Nov 22 '07 #6
dip_developer
648 Expert 512MB
Is it possible to redirect to a web page while sending data using POST method at the same time in ASP .NET?

I know that we can do it using GET method easily by doing Response.Redirect(URL + params) but is it possible to do redirection like that while sending data via POST method to that new page? Thanks.
by no means you can have a POST method with Response.Redirect.......................your idea of using javascript is very good and smart..........

Otherwise you have some options like...
Session/Cookies/Server.Transfer which are already told by others...

here is a discussion you can look into..........

http://www.velocityreviews.com/forum...t-method-.html
Nov 23 '07 #7
I'd recommend using a combination of Server.Transfer and HttpContext e.g:

Expand|Select|Wrap|Line Numbers
  1. Context.Items.Add(ENTITY_KEY,Entity);
  2. Server.Transfer(destination);
You can add any state you want into context using a key, value pair.

When you arrive on the destination page, you can then get your object back out of the Context collection (it will come out typed as an object so you will need to cast it back to the desired type):

Expand|Select|Wrap|Line Numbers
  1. Entity entity = (Entity)Context.Items[ENTITY_KEY
];

There's a great example here of how to use Server.Transfer, HttpContext and Viewstate to pass information across multiple pages:

http://www.metroget.com/post/2007/12...-Entities.aspx
Dec 8 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Victor | last post by:
I need to redirect to another web page, but that redirect will include the submission of form data. So, unlike ServerXMLHTTP which stays on the originating web page, I need the script to redirect...
2
by: Darren Oakey | last post by:
G'day - I have a problem that I just can't figure out how to solve, and would desperately love some help!!! We have an existing product (which we don't have control over) which is a web server...
6
by: DotNetGruven | last post by:
I've got a page that does a search... There is an ImageButton on it that allows the user to reset the search. The Click Handler for the button clears out the Data and then redirects to the same...
6
by: Keith Patrick | last post by:
I have to do some programmatic redirects (in several pages) based on URLs I am given from an external source. The URLs have querystrings at the end, but one in particular is about 240 chars long,...
2
by: ETK | last post by:
Hi, I need to POST data to some aspx page and after that redirect to this page ( page isn't on my local server where my page is). Is it possible to do this from aspx code on server side? Thanks,...
1
by: David | last post by:
I need to redirect to a page and HTTP Post data. The Response.Redirect does not work and the HTTPREQUEST option calls the page and waits for a response, but I need to transfer control to the...
3
by: Brano | last post by:
HI all, I am looking to post XML data to a particular page and also redirect to the same page. I have coded a WebReqest code in page0 that posts the XML to the page1 and then the page1 in its...
13
by: deko | last post by:
I have a basic feedback form with a submit button. After the "send" button is clicked, I want the user to be redirected to a different page that says "Your message has been sent." How do I do...
5
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
I am trying to create ASPX code which will allow me to redirect a user to another site with POST data. I figure that the best way to do this is with JavaScript to the client. Here's what I'm doing:...
56
by: UKuser | last post by:
Hi, I'm not sure if this can be done as I've searched the web and this forum. I am using an online merchant provider and I must post certain variables to their webforms through a form on my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.