Post Redirect Get in asp.net - asp.net

I'm interested in implementing PRG in my website for some forms I've created. At present they postback to themselves, and obviously refreshing these pages posts the data in duplicate. Can anyone point me in the direction of a good tutorial of how I can code this into my site? I understand the logic but am not sure exactly where to start.
Thanks

After you postback to the form you simply need to perform a redirect after the postback.
DoPostbackProcessing();
Response.Redirect("FormConfirmationPage.aspx");
As a very simple example, basically as long as you redirect (GET) to another page then the user cannot duplicate the postback. Of course if there are any errors in the forum you may not want to re-direct, but this is down to individual requirements.
EDIT: A good example of this is search, instead of posting back and then performing the search you would redirect and GET:
// Instead of performing search now we will redirect to ourselves with the criteria.
var url = "SearchPage.aspx?criteria=" + txtSearch.Text;
Response.Redirect(url);
This then redirects, the page then checks for a criteria query string and THEN performs the search, and when the user refreshes it searches again - plus they can bookmark the page for instant searching.

Related

Redirect a typeform page and show results on new page

I have a typeform form that has a different score per answer. At the end of the form I want to redirect to a page on my website (on Wordpress). On that page I want to have a section that has the form results (eg "you scored 5 out of 10").
Is there a way to carry these results onto my website?
I've tried researching web hooks, but I am lost.
I think this rather a Typeform question than a pure programmatic question.
On your Typeform you can create as many Thank you screen as you like.
Each thank you screen could have its own text and its own redirect link.
On the redirect link, you can pass a query parameter taking the value of the score calculated on Typeform. Click on the + button to select either a response to a question, a hidden field, or the calculated score.
And you can redirect the user to your Wordpress with a URL like
https://mywebsite.com?score={value from typeform}
If you have more questions you should contact Typeform support directly.

User input handler that returns data to page

I'm new to Wordpress developing and I have found what feels like a clumsy solution to a problem that seems like it should be common. Please help me find a cleaner solution with less potential for buggy behavior.
Objective: Get date range from user on a Wordpress page, use date range in API request, display data from API response on Wordpress page.
Current solution: Start and end dates are submitted via an HTML form in a Wordpress page with POST method. The POST request does not route to any other page. In addition to start and end parameters, the form has a hidden action parameter with a custom value I have specified: <input type="hidden" name="action" value="custom-value">. I have written a plugin that uses the init hook. The hooked function checks $_REQUEST['action'] to see if it matches the custom value in the form, and if so it does a GET request to an API (recreation.gov) using the start and end dates from the form. Up to this point, the solution seems pretty solid to me. Here's where the tutorials ran out and I had to get......inventive.
The data from the API request is processed and formatted into HTML, and this string is stored as a transient using set_transient with a 3 second lifespan. In the original page that the form was submitted from, there is a shortcode that simply returns the transient. Now I have the data from the API on the same page that the user specified the date range from.
This solution works, but seems like there is a high probability of things going awry if multiple users are using the page at the same time, and seeing or overwriting each others' results. There must be a better way to get the data from the plugin that does the API request back to the Wordpress page.
Since this question is about methodology, not syntax, I haven't included any example code, but I could if that would be helpful. Thanks in advance for your advice.
The solution I ended up finding was ditching the plugin and doing everything from inside a shortcode. Shortcode has access to $_REQUEST['action'], which I wasn't aware of, so I was able to get the user input and do the API call in the shortcode, then format the results and return them. No need to deal with plugins and hooks because the shortcode is executed as the page is loaded.

Wordpress redirect on password to certain page

My client would like to give each customer a password and once entered, this should then redirect them to a certain page. I.e. password 'cake' would go to a page about cakes, password 'cats' would go to a page about cats. Sounds simple enough, is there a plugin that you guys are aware of that would do it? Or is it possible straight from WP itself?
Thanks
Take a look at Peter's Login Redirect. I haven't used it myself, but it has good ratings, has been updated recently, and it sounds like it can redirect based on the login criteria entered.
On a side note, I can't wait to see this website that features cats and cakes!
Good luck.
I'm sure there are better solutions out there. I accomplished what you are looking for by using conditional fields and html in Gravity forms. To mimic a password, I removed the Gravity forms submit button, and I basically created my own submit button in the html field to redirect the visitor to my desired url. Using conditional fields, I hide the button until the user enters the exact passphrase.
This method also allowed me to create hide/show multiple buttons matching different passcodes. We give private clients different passcodes to redirect them to different pages and content.
I've searched for hours for that solution! Here You go #ajguk: http://thecodecave.com/plugins/smart-passworded-pages/ or http://wordpress.org/plugins/smart-passworded-pages/
The plugin is called "Smart passwor pages" (for those experts that can't reed what the link says). It is as close as it gets 4 me. The plugin is old, but it works. Instalation is simple. You just need to put shortcode [smartpwpages] on a page which gives You a login field and every childpage under page with shortcode (if passworded protected throug WP) will work exactly like you asked. You will need to enter into login field only a password and it will redirect user to a page that this password protects... Just need to make your passwords unique for every childpage.
Cheers!

How to redirect to a page after a fivestar vote in Drupal with Rules?

Drupal 6.22
Fivestar 6.x-1.19
Rules 6.x-1.4
These modules were the latest as of this posting.
My goal is to redirect a user to a page when they vote on a node. Should be simple enough.
I've created a rule for when a user votes on a node. No condition. I've added an action to add a message to the log to verify the rule is being triggered. Which it is. Then adding an action to redirect to the homepage (for testing). The redirect never happens. If I check the option "Immediately issue the page redirect", the ajax vote never saves and just hangs at "saving vote...".
I don't think I'm doing anything wrong and will post this to the fivestar module issues. Has anyone else had this issue?
http://drupal.org/node/252859
A "redirect to url ..." will definitely cause issues with Fivestar's AJAX voting mechanism. Here's what's happening:
What normally happens:
- User clicks on a Fivestar widget to rate.
- AJAX request is made by the current page.
- VotingAPI saves the vote.
- Fivestar generates XML and prints the page.
- The current page receives XML, then updates the voting widget with the new values.
What happens with VotingActions:
- User clicks on a Fivestar widget to rate
- AJAX request is made
- VotingAPI records the vote
- VotingActions hooks in and says "oh I'm redirecting this URL" <-- Where things go wrong
- Instead of returning XML to the calling page (which would update the votes), the original page gets back a full HTML page of wherever VotingActions redirected the page.
- Fivestar doesn't get to generate it's XML, because VotingActions has ended the execution by using a drupal_goto().
So I don't think it's a bug in either VotingActions or Fivestar, it's just a case of using two features in incompatible ways. To make this work, Fivestar would have to not be AJAX driven, instead reloading the page to save a vote.
Fivestar provides a nice JavaScript hook that you can use to go to the next page. If you add JavaScript to the page that contains something like this:
function fivestarResult(voteResult) {
window.location.href = 'http://google.com';
}

Page Redirect in SharePoint

How would I be able to redirect someone to a specific page based on their user profile information such as the department they are in?
I came up with 2 options:
Have a "My Department" link to a aspx page that uses SharePoint's object model to determine what department they are and then redirect based on their department.
Have an HTTPModule redirect the user after performing the user profile check.
Number 2 seems dumb, since it means we will be checking for every link we click.
Number 1 seems possible.
Is there a better way to redirect a user to a page based on their profile data?
I would go with number 1. You could even make a user control that calculates the link ahead of time and cache it per user to reduce load.
Check out Liam Cleary's blog, he has written and published a pretty sophisticated web part that does some of this:
http://www.helloitsliam.com/archive/2008/07/15/redirect-web-part-update.aspx
Is your goal to show personalized content? If so and you are using MOSS have you thought about using Audiences?

Resources