locked
Redirect from handlers page to .aspx page RRS feed

  • Question

  • User129610786 posted

    Hi All,

     I would like to share my problem. I have a .ashx page, from this page I would like to redirect to .aspx page but I am not able to do it. So, I am trying to call the .aspx page using SQL Server. If there is a chance to redirect .ashx to .aspx page I will be comfortable or else I need how to open a .aspx page using SQL. So please try to help me.. and the other issue is when I am trying to debug the highlighted code(/*xxx*/) while debugging  I am getting an error. Please help me.. Its urgent...

    Below is my code…

    Thanks in advance…

    public class Upload : IHttpHandler, IRequiresSessionState
    {
        public Upload()
        {
        }
    
        #region IHttpHandler Members
    
        public bool IsReusable
        {
            get { return true; }
        }
        public void ProcessRequest(HttpContext context)
        {
            string pagename = System.Web.HttpContext.Current.Session["pagename"].ToString();
            string strpath = context.Server.MapPath(context.Request.ApplicationPath);
    }
    
    if (pagename == "userdownload")
            {
                DataSet ds_selfiles = asignfiles.select_filestatus("0", System.Web.HttpContext.Current.Session["emailid"].ToString(), Convert.ToDateTime(DateTime.Now));
    
                //string mtname = System.Web.HttpContext.Current.Session["emailid"].ToString();
                //string hospname = System.Web.HttpContext.Current.Session["hospname"].ToString();
                //string Docname = System.Web.HttpContext.Current.Session["docname"].ToString();
    
                for (int j = 0; j < context.Request.Files.Count; j++)
                {
    
                    HttpPostedFile uploadFile = context.Request.Files[j];
                    string path = context.Server.MapPath(context.Request.ApplicationPath + "/MT Documents");
                    if (!Directory.Exists(Path.Combine(path, DateTime.Now.Date.ToString("dd MMM yyyy"))))
                    {
                        Directory.CreateDirectory(Path.Combine(path, DateTime.Now.Date.ToString("dd MMM yyyy")));
                        //string path1 = Path.Combine(path, DateTime.Now.Date.ToString("dd MMM yyyy"));
                    }
                    string path1 = Path.Combine(path, DateTime.Now.Date.ToString("dd MMM yyyy"));
                    DataSet ds = Hospitaldetails.create_hospitalname("0", System.Web.HttpContext.Current.Session["emailid"].ToString());
                    int rowcount = ds.Tables[0].Rows.Count;
                    for (int b = 0; b < rowcount; b++)
                    {
                        if (!Directory.Exists(Path.Combine(path1, (ds.Tables[0].Rows[b].ItemArray[0].ToString()))))
                        {
                            Directory.CreateDirectory(Path.Combine(path1, (ds.Tables[0].Rows[b].ItemArray[0].ToString())));
                        }
                        string path2 = Path.Combine(path1, (ds.Tables[0].Rows[b].ItemArray[0].ToString()));
                        if (!Directory.Exists(Path.Combine(path2, (ds.Tables[0].Rows[b].ItemArray[1].ToString()))))
                        {
                            Directory.CreateDirectory(Path.Combine(path2, (ds.Tables[0].Rows[b].ItemArray[1].ToString())));
                        }
    
                        string uploadPath = Path.Combine(path2, (ds.Tables[0].Rows[b].ItemArray[1].ToString()));
                        string uploadPath1 = context.Server.MapPath(context.Request.ApplicationPath + "/Final Documents");
                        if (!Directory.Exists(Path.Combine(uploadPath1, DateTime.Now.Date.ToString("dd MMM yyyy"))))
                        {
                            Directory.CreateDirectory(Path.Combine(uploadPath1, DateTime.Now.Date.ToString("dd MMM yyyy")));
                            //string path1 = Path.Combine(path, DateTime.Now.Date.ToString("dd MMM yyyy"));
                        }
                        string uploadPath2 = Path.Combine(uploadPath1, DateTime.Now.Date.ToString("dd MMM yyyy"));
                        // DataSet ds = Hospitaldetails.create_hospitalname(System.Web.HttpContext.Current.Session["emailid"].ToString());
                        // int rowcount = ds.Tables[0].Rows.Count;
                        // for (int b = 0; b < rowcount; b++)
                        // {
                        if (!Directory.Exists(Path.Combine(uploadPath2, (ds.Tables[0].Rows[b].ItemArray[0].ToString()))))
                        {
                            Directory.CreateDirectory(Path.Combine(uploadPath2, (ds.Tables[0].Rows[b].ItemArray[0].ToString())));
                        }
                        string uploadPath3 = Path.Combine(uploadPath2, (ds.Tables[0].Rows[b].ItemArray[0].ToString()));
                        if (!Directory.Exists(Path.Combine(uploadPath3, (ds.Tables[0].Rows[b].ItemArray[1].ToString()))))
                        {
                            Directory.CreateDirectory(Path.Combine(uploadPath3, (ds.Tables[0].Rows[b].ItemArray[1].ToString())));
                        }
                        string uploadPath4 = Path.Combine(uploadPath3, (ds.Tables[0].Rows[b].ItemArray[1].ToString()));
                        string uploadPath5 = context.Server.MapPath(context.Request.ApplicationPath + "/MT Docs");
                        // string uploadPath2=Path.Combine(path2, (ds.Tables[0].Rows[b].ItemArray[1].ToString()));
                        strpath += "~" + uploadPath;
                        strpath += "~" + uploadPath4;
                        strpath += "~" + uploadPath5;
                        if (uploadFile.ContentLength > 0)
                        {
    
                            uploadFile.SaveAs(Path.Combine(uploadPath, uploadFile.FileName));
                            uploadFile.SaveAs(Path.Combine(uploadPath4, uploadFile.FileName));
                            uploadFile.SaveAs(Path.Combine(uploadPath5, uploadFile.FileName));
                            string strFileExtension = System.IO.Path.GetExtension(uploadFile.FileName);
                            object fileName = Path.Combine(uploadPath, uploadFile.FileName);
                            object readOnly = false;
                            object isVisible = true;
                            object missing = System.Reflection.Missing.Value;
                            /* Microsoft.Office.Interop.Word.ApplicationClass oWordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
    
                             Microsoft.Office.Interop.Word.Document oWordDoc = oWordApp.Documents.Open(ref fileName,
                                                          ref missing, ref readOnly,
                                                          ref missing, ref missing, ref missing,
                                                          ref missing, ref missing, ref missing,
                                                          ref missing, ref missing, ref isVisible,
                                                          ref missing, ref missing, ref missing, ref missing);
    
                             oWordDoc.Activate();
                             Int32 count = oWordDoc.Characters.Count - 1;
                             oWordDoc.Close(ref missing, ref missing, ref missing);*/
                            String m = uploadFile.FileName;
                            String extnsn = Path.GetExtension(m);
                            System.Web.HttpContext.Current.Session["name"] = Path.GetFileNameWithoutExtension(m);
                            DataSet ds_docnames = uploadfiles.select_docname(m);
                            if (ds_docnames.Tables[0].Rows.Count == 0)
                            {
                                asignfiles.insert_uploaded_docmnt_details(ds_selfiles.Tables[0].Rows[0].ItemArray[1].ToString(), ds_selfiles.Tables[0].Rows[0].ItemArray[2].ToString(), ds_selfiles.Tables[0].Rows[0].ItemArray[3].ToString(), ds_selfiles.Tables[0].Rows[0].ItemArray[4].ToString(), Convert.ToDateTime(ds_selfiles.Tables[0].Rows[0].ItemArray[5].ToString()), ds_selfiles.Tables[0].Rows[0].ItemArray[6].ToString(), ds_selfiles.Tables[0].Rows[0].ItemArray[7].ToString(), ds_selfiles.Tables[0].Rows[0].ItemArray[8].ToString(), ds_selfiles.Tables[0].Rows[0].ItemArray[9].ToString(), ds_selfiles.Tables[0].Rows[0].ItemArray[10].ToString(), ds_selfiles.Tables[0].Rows[0].ItemArray[11].ToString(), uploadFile.FileName, "Transcribed", 0, Convert.ToInt32("00"), Convert.ToInt32("00"));
                            }
                        }
    
                    }
                    if (ds_selfiles.Tables[0].Rows.Count != 0)
                    {
                        int i = asignfiles.update_filestatus_MT("Transcribed", ds_selfiles.Tables[0].Rows[0].ItemArray[2].ToString());
                        //asignfiles.insert_finishedtime("0", ds_selfiles.Tables[0].Rows[0].ItemArray[2].ToString(), Convert.ToDateTime(DateTime.Now.ToString("hh:mm tt")), "Transcribed");
                        asignfiles.update_asignedtime("0", ds_selfiles.Tables[0].Rows[0].ItemArray[2].ToString(), Convert.ToDateTime(DateTime.Now.ToString("hh:mm tt")));
                        HttpContext.Current.Response.Write(strpath + "/user_download.aspx");
                    }
                }



    Thursday, May 9, 2013 3:23 AM

All replies

  • User840877147 posted
    context.Response.Redirect(target_url);

    Thursday, May 9, 2013 9:54 AM
  • User129610786 posted

    Hi Nikil,

            Thanks for your reply,but  I have already tried your code 

    context.Response.Redirect(target_url);

    and also

    HttpContext.Current.Response.Redirect("~/user_download.aspx",false);

    HttpContext.Current.Response.Redirect("/user_download.aspx");

    context.response.redirect("~/user_download.aspx");

    But there was no use....

    Friday, May 10, 2013 2:32 AM
  • User-691245060 posted

    Better you do it with a HttpModule with Server.Transfer()....

    thanks,

    Friday, May 10, 2013 3:22 AM
  • User129610786 posted

    Hi Rami,

    Even I tried with server.transfer()... But no use...Cry

    Saturday, May 11, 2013 12:59 AM