asp.net interview: How to redirect a page to another page?
A common question asked in interviews. The Response object has a famous Redirect method that is used most widely to transfer a web page visitor from one page to another page.
Syntax of Response.Redirect ...
Response.Redirect("DestinationPage.aspx")
There is another famous method called Transfer method of the Server object.
Syntax of Server.Transfer ...
Server.Transfer("DestinationPage.aspx")
ASP.NET Page Life Cycle Overview
| Stage | Description |
| Page request | The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page. |
| Start | In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets theIsPostBack property. Additionally, during the start step, the page's UICulture property is set. |
| Page initialization | During page initialization, controls on the page are available and each control's UniqueIDproperty is set. Any themes are also applied to the page. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state. |
| Load | During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state. |
| Validation | During validation, the Validate method of all validator controls is called, which sets the IsValidproperty of individual validator controls and of the page. |
| Postback event handling | If the request is a postback, any event handlers are called. |
| Rendering | Before rendering, view state is saved for the page and all controls. During the rendering phase, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page's Response property. |
| Unload | Unload is called after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed. |
What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?
Some of we developers may confused about these 2 method,
Server.Transfer() : client is shown as it is on the requesting page only, but the all the content is of the requested page. Data can be persist accros the pages using Context.Item collection, which is one of the best way to transfer data from one page to another keeping the page state alive.
Response.Dedirect() :client know the physical loation (page name and query string as well). Context.Items loses the persisitance when nevigate to destination page.
In earlier versions of IIS, if we wanted to send a user to a new Web page, the only option we had was Response.Redirect. While this method does accomplish our goal, it has several important drawbacks. The biggest problem is that this method causes each page to be treated as a separate transaction. Besides making it difficult to maintain your transactional integrity, Response.Redirect introduces some additional headaches. First, it prevents good encapsulation of code. Second, you lose access to all of the properties in the Request object. Sure, there are workarounds, but they’re difficult. Finally, Response.Redirect necessitates a round trip to the client, which, on high-volume sites, causes scalability problems. As you might suspect, Server.Transfer fixes all of these problems. It does this by performing the transfer on the server without requiring a roundtrip to the client.
Guidelines for a Strong Job Interview
Behavioral-based interview questions are focused on bringing specific past projects, accomplishments and failures to light. Employers look for key past behaviors. With the notion that past behaviors are a strong indicator of future behaviors, the hiring managers in today's marketplace will probe deep into your business life to see if you match up. The more recent the story about your career, the more relevant it will be in the mind of the interviewer. Use "I" versus "we" when telling your past story. They are interested in your contributions and business behaviors, not someone else's. Here are five key basics to know when answering behavioral-based questions:
1. Do not answer with an opinion, a theory or a vague response.
Behavioral-based questions are targeting your past. Your opinion is simply your view or belief, and offers no detail around what you did on the job. A theoretical response carries no weight, as it is not valid experience. A vague response keeps the hiring manager guessing, and most likely probing further to extract the information that they are after.
2. Perform a dress rehearsal.
Write down specific behavioral-based questions that you may hear, and role-play with someone who will give you "tough love" in return. This will keep your stories to a minimum, keep you focused on using the STAR format, and give you the necessary confidence to make that all-important positive impression.
3. Avoid tangents.
It's easy to keep talking about your past successes and accomplishments. Be warned, too many times the Interviewee keeps adding on to their story. Once you have provided the specific and measurable Results, stop talking. The interviewer will probe further if more information is required.
4. It's OK to pause before answering.
Preparation works well for behavioral-based questions, however, you may hear a question that you didn't expect. Ask for a moment to collect your thoughts, and then follow the STAR format to response to the question.
Tip 6 Interview Questions Decoded
Job seekers should be aware that every question an interviewer asks is an opportunity to sell themselves as the most outstanding, must-have candidate for the job. In their book, Warner and Bryan identify some of the most popular interview questions, reveal what interviewers really want to know when asking them and offer tips to help job seekers develop a savvy response.
These questions include:
1. Would you be willing to pursue an extra certificate or credential?
What they're really asking: How is your attitude? How flexible are you?
Tips: Tell the interviewer how important professional growth is to you. Understand that the person who will impress the interviewer the most is the one willing to do the extra work.
2. Tell us about yourself.
What they're really asking: What makes you special? Why should we hire you?
Tips: Prepare several selling points about yourself. Give a quick "elevator speech" that overviews your experience and achievements.
3. What are your greatest strengths?
What they're really asking: How do you perceive your talents and abilities as a professional? Will you be an asset to our organization?
Tips: Sell yourself. If you don't promote your strengths, nobody else will. Prepare six or seven responses. Be "confidently humble."
4. Do you have any questions for us?
What they're really asking: Are you prepared to ask questions? How interested are you in this position?
Tips: List five or six questions on an index card. Ask at least one question, even if all of your prepared questions have been answered. Never say, "No, you've answered all of my questions."
5. What are your greatest weaknesses?
What they're really asking: How honest are you being about yourself with us? How realistic are you?
Tips: Present your weakness as a positive. Don't talk too long or emphasize your downfalls.
6. Why are you interested in working here?
What they're really asking: How dedicated are you? Do you have a passion for this type of work?
Tips: Keep your answer simple and to the point. Stay away from such responses as, "Many of my friends have worked here." This response isn't very impressive.
How to Formulate Questions
The correctness and appropriateness of the answers that we get depends on the strength and correctness of the question itself. An insufficient response is elicited from a weakly constructed question. Before you even scrutinize the answers that were given, evaluate first the character of the question. Formulating questions the proper way is what generates an adequate answer.
The first step in formulating questions is to assess the level of importance of the basic question words “who,” “where,” “when,” “what,” “how,” and “why.” The first four are classified as informational since these questions generally gather factual information or knowledge such as “What is the goal for this activity?” or “Who are responsible in spearheading the event?” The last two question words belong to the analytical category since these questions require a higher level of thinking and a deeper means of understanding a concept.
The next step is to know how to prioritize within each category. A good basis to easily apply this is through the concept of Bloom’s taxonomy where the level of questions is organized from the lower order to the higher order of questioning.
Focus on the very important elements which can be used as the keywords in your question. Then, explore the different connections, precedents, implications, and causations of the question.
In asking questions that require analytical approach, consider gathering a few factors instead of focusing on just one. Always ask “why” as a way to make the response more deductive and specific.
5 Things You Should Have Said at the Job Interview
Scenario No. 1: "Why are you looking to leave your existing position?" is another typical question, one that you were expecting but weren't quite sure how to address. Your motive is grounded in bad feelings, and you blurt out, "My boss is out to get me. I'm tired of being looked over for promotions."
What you should have said: Honesty is always the best policy when answering interview questions. There is a difference, however, between shooting yourself in the foot and providing a straightforward response. If you're leaving a position because of office politics, the interviewer doesn't need to know the specifics. As a result, a neutral response such as, "I've advanced as far as I can with ABC Co. So I'm looking for a position where I can manage a larger territory and bring in lucrative accounts," works well because it's truthful without over sharing.
Scenario No. 2: Since the average person searches for a new job about every two years, the interviewer wanted to know how long you planned to stay with the company if hired. Not sure how to respond, you said, "Until retirement." At first blush, the response sounds like a good one, because you're making a commitment to the hiring organization. But the response comes off as brown-nosing and not entirely believable in today's environment.
What you should have said: Show your ambition alongside your dedication by saying, "I plan on staying on board as long as I'm contributing to the department and growing professionally."
Scenario No. 3: The interviewer asked, "Why should I hire you?" You listed strengths that align with the open position. Although there's nothing technically wrong with your response, you could have taken your answer a step further.
What you should have said: "That's a fair question. Instead of providing a canned response, I'd like to participate in an audition interview so you can see my work ethic firsthand." An audition interview is when you perform the tasks of the position as though you were hired. This way, the hiring manager can see your performance before extending an official job offer.
Scenario No. 4: You committed an interview misstep by arriving late. Nervous, you rambled with a long excuse, bringing prolonged attention to your blunder.
What you should have said: Apologize and move on quickly. Extend your hands and say, "My apologies for my late arrival. I'm enthusiastic about the position and am looking forward to discussing how my accomplishments support the open requirements."
Scenario No. 5: Toward the end of the interview, you were given an opportunity to raise questions. You asked typical questions, such as, "How soon do you expect to make a decision?" but stopped short of asking for the job outright.
What you should have said: "Based on today's conversation, do you have any reservations about extending me a job offer? If the interviewer provides a reason for hesitation, resell your qualifications. If the interviewer says "no," respond with, "I'm interested in the position. Can I have the job?" You'll be surprised that many will hire you contingent on a referral check.