Solved

Response.Redirect doesn't work in any processing is done on aspx page

Posted on 2004-08-25
5
1,661 Views
Last Modified: 2013-12-23
Hi,
Recently, I have been experiencing sparadic problems with Response.Redirect in aspx pages. I created a new web project using vb.net and setup my image buttons for redirection and they work fine. However, when I load some dropdownlist controls when the pages loads for the first time, and click the image button, I get the error "The page cannot be displayed". I comment out the subs that load the dropdowns and viola, the page redirects. I'm connecting to SQL Server 2K with the sqlclient object.

Is this happening to anyone else and how do I fix it? This happened a few weeks ago also, but mysteriously quit. If anyone can help or give me some direction on this, it is appreciated greatly!

Thanks!
0
Comment
Question by:Ponyboy99
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:LlamaJoe
ID: 11898984
since you're doing the response.redirect when the page posts back, there are a couple things we can look at.  Your best bet is to post the code and we can take a look and probably give you an answer very quickly.

0
 
LVL 11

Expert Comment

by:ajaikumarr
ID: 11899778
Hai,

Try encapsulating all code in the Function:
Private Sub Page_Load(
.....
with:

If Not Page.IsPostBack Then
.....
End if

Bye
Ajai
0
 

Author Comment

by:Ponyboy99
ID: 11901926
The procedure calls to load the data are in a "If Not IsPostBack" statement in the Page_Load event as follows:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not IsPostBack Then
            LoadProviderNames()
            LoadProviderSSNs()
            LoadProviderTINs()
        End If
    End Sub

These load 3 respective dropdown lists using System.Data.SQLClient methods to a SQL Server 2000 database:
(all three procedures are identical, substituting the ddlProviderName.* with ddlProviderSSN.* and ddlProviderTIN.* and the called views as SSNLookupProv and TINLookupProv)

      Dim sConnection As String = GetConnectionString(giConnTypeNP, Server.MapPath(gsConnFilePath))
        Dim conn As New SqlConnection(sConnection)
        Dim cmd As SqlCommand
        Dim myReader As SqlDataReader
        Dim sSQL As String = ""
        Try
            conn.Open()
            'fill the providername ddl
            sSQL = "Select Name from NameLookUp"
            cmd = New SqlCommand(sSQL, conn)
            myReader = cmd.ExecuteReader
            If myReader.HasRows Then
                ddlProviderName.Items.Clear()
                ddlProviderName.Items.Add(" ")
                Do While myReader.Read
                    ddlProviderName.Items.Add(myReader.GetValue(0))
                Loop
            End If
            cmd.Dispose()
            cmd = Nothing
            myReader.Close()
            myReader = Nothing
            conn.Close()

            If conn.State <> ConnectionState.Closed Then
                conn.Close()
                conn.Dispose()
                conn = Nothing
            End If
        Catch ex As Exception
            If conn.State <> ConnectionState.Closed Then
                conn.Close()
                conn.Dispose()
                conn = Nothing
            End If
            Session("Exception") = CleanException(ex.Message.ToString)
            Response.Redirect("errorpage.aspx")
        End Try

And the page loads fine, however when you click on the image button control ibtn0, no work is done and the get the "Page cannot be displayed" http error page is displayed. It will not even hit a breakpoint in the ibtn0_Click event unless I use a simple html <A href> link instead of a button control. Note that ALL other button events work as expected everywhere else in the program and on this page, unless any processing is done as shown in the procedure above. One procedure call and everything is fine, more than one procedure call and nothing. Currently, these are the only 4 procedures addressed on this aspx page of the program.
This is the ibtn0 event:

    Private Sub ibtn0_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibtn0.Click
        Response.Redirect("ProviderEdit.aspx")
    End Sub

Like I said, I had this occur a few weeks ago, but it mysteriously went away & I never had another problem till now. I am at a total loss to explain or fix it and have found no reference to this type of problem. Any help is greatly appreciated.
Thanks!


0
 
LVL 5

Accepted Solution

by:
LlamaJoe earned 500 total points
ID: 11919405
go to c:\windows\Microsoft.Net\Framework\v1.x.x\Temporary ASP.NET Files\ and delete all the files related to this application - then do a rebuild solution (not a build solution) and see if this takes care of your problem.
0
 

Author Comment

by:Ponyboy99
ID: 11998692
This didn't help, but the standard .net button controls work correctly. I've been through IIS and verified security permissions on the folders and they are correct. I'm to the point of starting a new project & redoing the code from scratch just to see if there is something I inadvertantly screwed up. Thanks.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. This will be demonstrated using a Windows 8 PC Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php :…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now