Best practice for URL redirection in ASP.NET web application -


I have an asp page (Default.aspx) that shows the difference between two text files. It has two drop down lists (respectively id = "file1" and "file2" respectively) and a button (id = "submit").

There is also a lexical control with the id "result".

The content of the list button is populated based on the files present in the physical application path.

Each time the submit button is clicked, I want to give the result of diff / comparison in literal control, so I have an event handler like this:

  protected Zero Submit_Click (Object Sender, EventArgs e) {Results.First = Comparison Files (File 1. Selected Price, File2.SelectedValue); }  

The problem with this is that you can not bookmark results of comparison between specific files.

To solve this problem, I compare the values ​​of the selected files as a query string for the added URL and made a redirection. And so, the above event handler has been changed to look like this:

  Protected Zero Submit_Click (Object Sender, EventArgs e) {string build1 = DropDownList1.SelectedValue; String build 2 = dropdown list 2. Value selected; String queryString = String.Format ("? File1 = {0} and file2 = {1}", HTTP://rlncode (build1), HTTPProblem .URLNode (build2)); String Redirection URL = Request. Url Azollite path + quickstring; reaction. Redirect (Redirection URL, True); }  

Accordingly, the "comparison file" method was called in the "Page_Load" event handler, now you can bookmark the results of the comparison and load it directly because the URL There should be files to compare.

But the problem is that "IsPostBack" property is wrong every time there is redirection. Therefore, the value of the dropdown list (files contained in the physical application directory) is evaluated each time.

I should not do this if this is a redirection from the same page How can I do this? I only want that if the page is accessed for the first time or accessed from another page.

Is this a bad practice? I mean redirecting to the same page I can avoid this problem by giving the result to a different page, but I want to do it this way because I always want the dropdown list and the "submit" button always.

Since you are redirecting to the same page, this is not a postback, the viewer is lost , And it will have to re-attach the contents.

More than likely, only the dropdown list has been cached, then you can load it from the cache, and can not just press the file system in the cache.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -