So I am junior programmer, and I just started working with .net webforms a little over six months ago. I have been studying SEO, and trying to optimize best practices with a senior level developer. I feel like 302s or in .net webforms response.redirect is misused alot. It could just be our team's logical flow of processing. However with how webforms handle state such as with Server.Transfer, controls, viewstate, and the page lifecycle I feel like this isn’t true. I sorta feel like we are forced in some ways for ease of programming to use Response.Redirect. We are looking for the best way to handle Response.Redirect and feel like we possibly misuse it. Maybe this only matters for public pages considering search engines will split page ranking between two pages if a Response.Redirect is used. Overall we want to have best practices, and establish the best principles for our team.
Scenario 1: Use event attached to a checkbox control, when user clicks a postback is performed. In event within code behind we build the querystring based on the checkbox selection, and do a Response.Redirect to the same page. On first time page, check querystrings, and show results.
- Seems to me as not being a temporary redirect. Content may change but overall the page at that URL will always be there. Its not even a new page. That checkbox will always go to that URL. Shouldn't this just be a get request. To me instead of just doing a Response.Redirect it would be best to just change the results based on selection. Creating a single reusable function for this logical flow.
Scenario 2. We have an admin page with a grid displaying rows of information related to particular entities. Each row has a button corresponding to a details page for editing the entity. When the user clicks a button within a row on the grid, a postback is performed, an encrypted token is built based on the row item selected. Response.Redirect is performed to go the details page with the token passed as a querystring parameter.
- Doesn't seem like a temporary redirect to me. Everytime you click that button it will go to that particular items details page. The only workaround I could come up with is to build each row items url with the token, on first time page load. Instead of doing a post, redirect, get, it will be just a get.
This is just two scenarios where we use Response.Redirect. We could probably show 10 to 15 common use cases that we use for Response.Redirect, and all of them seem misused in my opinion. Is this just the best way to do things in the webforms stack? How would a MVC application handle scenarios 1 and 2, would a redirect be preferred? I feel like each of our usecases needs to be examined, and determine best approach to avoid Response.Redirect. The lead developer of the project is looking for a single solution to handle all usecases for simplicity, less programming hours and without major architectural changes. I haven't been able to develop a solution that satisfies his requirements.
Note: added MVC tag because maybe one of the senior devs who has worked with both stacks (webforms and mvc) can answer the questions/concerns better.