Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7517995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:37:33+00:00 2026-05-30T01:37:33+00:00

I have a File.aspx form where I display all the files. When I upload

  • 0

I have a File.aspx form where I display all the files.

When I upload a file I am using a upload.aspx file to run c# code to upload the file.

The thing is that at the end , I want to refresh the page automatically to display the new file upload but apparently it’s not redirecting even if all the parameters are good.

This is the code I use

        HttpContext postedContext = HttpContext.Current;
        string param = Request.UrlReferrer.Query;
        string param2 = Request.UrlReferrer.Query;
        var url = HttpUtility.ParseQueryString(param).Get("projectName");
        var url2 = HttpUtility.ParseQueryString(param2).Get("projectId");
        HttpPostedFile file = postedContext.Request.Files[0];
        string name = file.FileName;
        byte[] binaryWriteArray = new
        byte[file.InputStream.Length];
        file.InputStream.Read(binaryWriteArray, 0,
        (int)file.InputStream.Length);
        //FileStream objfilestream = new FileStream(Server.MapPath("~\\" + "\\Files\\" + url + "\\" + name), FileMode.Create, FileAccess.ReadWrite);
        FileStream objfilestream = new FileStream(("C:\\inetpub\\wwwroot\\Clientportal\\Files\\" + url + "\\" + name), FileMode.Create, FileAccess.ReadWrite);
        objfilestream.Write(binaryWriteArray, 0, binaryWriteArray.Length);

        objfilestream.Close();
        string[][] JaggedArray = new string[1][];
        JaggedArray[0] = new string[] { "File was uploaded successfully" };
        JavaScriptSerializer js = new JavaScriptSerializer();
        string strJSON = js.Serialize(JaggedArray);
        Response.Write(strJSON);

        Response.Redirect(string.Format("Files.aspx?projectId={0}&projectName={1}", url2, url));

Any ideas ? I’m a bit stuck because I use this response.redirect everywhere and it works only when the code is in the same code file…

Maybe it’s because of the fact that I try to redirect from another code file ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:37:34+00:00Added an answer on May 30, 2026 at 1:37 am

    I would attempt to do reload on client side by using javascript:

    window.location.reload()
    

    if the JSON you get as a response contains message “File was uploaded successfully”
    If you are not using ajax for submitting the file you don’t need to write json. It’s enough to redirect to the suitable url that contains a parameter that identifies status of file upload operation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the filesystem I have /file.aspx /directory/default.aspx I want to configure IIS so that
I have an .aspx file that outputs an image using the following methods: Server.MapPath(somefile.png)
In my .aspx.cs I have a code that reads a .xml file and I
I have a page base class that has no .aspx file and so I
HI, I have and aspx form in which i am referring a JavaScript file.
i have a problem with jquery form plugin. I try to upload a file
I have a popup with a form containing file upload cfgfile <form id=mainForm method=post
We have a couple mini-applications (single Web form look-up stuff) that need to run
(Warning - asp newbie) I have an aspx file with the tag <%@ Page
I have an updateprogress in my aspx file, which has a label control in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.