Click here to Skip to main content
15,904,346 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I had written the code under the Global.asax. Here the error message was "The page isn't redirecting properly...".HOW CAN I REDIRECT TO ANOTHER PAGE..?PLZ SUGGEST ME ...

C#
void Application_BeginRequest(object sender, EventArgs e)
    {
       
        cmd = new System.Data.SqlClient.SqlCommand("sp_Checkurl", con_obj.conn);
        cmd.CommandType = System.Data.CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@url", url);
        da = new System.Data.SqlClient.SqlDataAdapter(cmd);
        ds = new System.Data.DataSet();
        da.Fill(ds);
        con_obj.Conn_close();
        if (ds.Tables[0].Rows.Count > 0)
        {
HttpContext.Current.Response.Redirect(url);
         Dispose();
         }
        else
        {
                                  HttpContext.Current.Response.Redirect("http://localhost:51262/Mywebsite/Blankpage.aspx");
         Dispose();
         }
      }
Posted
Updated 5-Sep-13 21:01pm
v7

Instead of
C#
HttpContext.Current.Response.Redirect(url);


try writing
C#
Server.Transfer(url)
and see if it works.
 
Share this answer
 
Hi i am sanny.Here we should put the only one redirect page like below

C#
if (ds.Tables[0].Rows.Count==0)
        {
HttpContext.Current.Response.Redirect(url);
         Dispose();
         }
 
Share this answer
 
C#
if (Request.Url.OriginalString.Contains("handler.aspx?menu_id="))
                {
                    Context.RewritePath("~/Handler.aspx");
                    return;
                }


it should be like this and return for next statement should not be implemented

regards...:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900