I am working on asp.net application.the user is clicks on some link which is inside grid item template field. if he is not logged in then he redirects to login page. after log in he is properly coming back to same page;the problem is that "i have passed the value in querystring to the page where he click on the link and after loggedIn the grid is showing blank because that grid is not getting query string value" I think you understand my problem.plz share your helpful opinion.
http://www.aspdotnetfaq.com/Faq/what-is-the-difference-between-server-transfer-and-response-redirect-methods.aspx
It is not a defect, but the desired behavior of Response.Redirect.
Store value in session and retrieve it after he gets back successfully from the login page.
Related
Sorry to ask but I don't what is the exact call on this.
I have a scenario for example I paste this link localhost/Dashboard/Treatment the user will go back to the login page once the user logged it will go to this localhost/Dashboard/Treatment instead of Main Page using asp.net.
I need is only the exactly the call on this process so that I will do the research.
Sorry beginner :)
If you are using login control, you can use DestinationPageUrl property in your code.
If you just use things like text boxes and button controls, then in your Button_Click event, you can just use Response.Redirect("DestinationHere").
If you don't want change anything in your page, you can add return RedirectToAction({actionName}, {controllerName}); in your login method.
I'm creating a form that a user has to completely fill out before they are able to register for a website. What i'm trying to counter is if the user gets to url of the second page by accident. I've tried using if(!isPostBack) and then inside the if statement redirecting them to the first page but that only works the first time, and the user can never hit the second page that displays their details when they click on the submit button because the second page is now a post back. Any help would be greatly appreciated!
There are several ways of doing this. You could use Session to store user progress. Also, if you have a long multi-page form you could have a master table for your form in the database that tracks user progress (column named ProgressPage, for example).
On a page in a website, I am giving a link to the login page of my asp.net website.
While i click on the link, I want to capture some information which is available on the page and pass it to my website's first page. Is there any way I can do it ?
Yes you can use the Query String , if the data is small , you can get the information on query string from this Link
You can set the required values in QueryString in the Url.
Check this: HttpRequest.QueryString Property
Also, You can use LinkButton and Handle its click event. On the Click Event you can set the required information in Cookie or Session as per you need.
There are many ways to capture the State. Follow these tutorials or google it for State Management tutorial. here are some:
http://www.codeproject.com/Articles/331962/A-Beginner-s-Tutorial-on-ASP-NET-State-Management
http://www.codeproject.com/Articles/492397/State-Management-in-ASP-NET-Introduction
http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx
I am building a wizard using asp.net mvc. currently when the user hits next (or previous) the form values are posted to an action which does any processing required and then renders the next view.
the problem i am having is that if the users hit refresh in that new view they get prompted to re-post the form values which causes a ton of problems.
In firefox i am getting the message: "To display this page, the application must send information that will repeat any action (such as a search or order confirmation) that was performed earlier."
Is there any way to prevent users from being able to re-post back to the action?
Thanks in advance.
Using the PRG pattern.
http://en.wikipedia.org/wiki/Post/Redirect/Get
I have 3 asp.net pages: Search.aspx, Results.aspx and Login.aspx.
Now I want anonymous users to be able to search, so everyone can use search.aspx. This page calls
Server.Transfer(Results.aspx)
and therefore shows the results. Now when the user is not logged in, a link to the login page is displayed on the Results page. The problem is:
After the login, I want the user to be redirected automatically to the Results page. However I do not succeed so, as the PreviousPage property of Login.aspx is always null. And when I use
Request.UrlReferrer.LocalPath
it's the link to Search.aspx but not Results.aspx.
Also, when the user is on the Results page, how do I enable him to go back by clicking a link and all his search input criteria (like in textboxes) on the Search.aspx is still there so he can refine the search after having seen the results? Whenever I send the user back, all user input is lost.
I still haven't figured out if I should use a normal hyperlink, a linkbutton and how to retrieve the previous page url or preserve the input data.
I can use AJAX if that is any help, but a "pure" asp.net solution would be preferred.
When you do a Server.Transfer it is a serverside redirect...meaning the client still sees the original URL. You need to post the search criteria to the results page, store them locally, show the login link. When they are logged in you can redirect to the results page and rehydrate the search critera and show the results.
Try using Response.Redirect("url") instead of Server.Transfer. When you use Server.Transfer, the url on the client will remain the Search page and not actually redirect to the Results.
You can use User.Identity.IsAuthenticated to check if the user is logged in and show/hide the login button based on that.
To keep values for the page, you could store them in Session, then have the Search page look for them and, if they exist, place them in the controls.
You can also embed the URL you want to return to after login into the querystring if you want.