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 721471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:52:38+00:00 2026-05-14T05:52:38+00:00

It’s pretty difficult to show code for ASP.NET here, so I will try my

  • 0

It’s pretty difficult to show code for ASP.NET here, so I will try my best to describe my problem.

I have a FileUploadControl and a Button that calls a function when it’s clicked. It seems that the Button function works when there is nothing chosen for my FileUploadControl. However, when there is something chosen in the FileUploadControl (I have selected a file to upload), there is a problem when I click the button. It completely does not matter what the function does (it could just be writing to a label, even when it has nothing to do with the FileUploadControl). The error I get is:

This webpage is not available.

The webpage at http://localhost:2134/UploadMedia/Default.aspx might be temporarily down or it may have moved permanently to a new web address.

I have searched on Google, and people seem to have had problems with this, but different causes from me. They have said that their ASP.NET Development Server port is actually different from their port in the address bar. This is not the case for me.

Also, another problem people have had is with Use Dynamic Ports. I have tried both true and false. I have also tried different ports, and I have always gotten the same error.

This is really driving me crazy because it doesn’t matter what the code in the buttonFunction is, it doesn’t work as long as there is something in the FileUploadControl. If there is nothing, it seems to work fine.

Here is the code for the ASP.NET Controls:

<asp:FileUpload id="FileUploadControl" runat="server" />
<asp:Button runat="server" id="UploadButton" text="Upload" OnClick="uploadClicked" />
<br /><br />
<asp:Label runat="server" id="StatusLabel" text="Upload status: " />

And this is the code for the button function:

protected void uploadClicked(object sender, EventArgs e)
{
    if (FileUploadControl.HasFile)
    {
        string filename = Path.GetFileName(FileUploadControl.FileName);

        //Check if the entered username already exists in the database.
        String sqlDupStmt = "Select songPath from Songs where songPath ='" + Server.MapPath("~/Uploads/") + filename + "'";
        SqlConnection sqlDupConn = new SqlConnection(@"Data Source = .\SQLEXPRESS; AttachDbFilename = |DataDirectory|\Database.mdf; Integrated Security = True; User Instance = True;");
        SqlCommand sqlDupCmd = new SqlCommand(sqlDupStmt, sqlDupConn);
        sqlDupCmd.Connection.Open();
        SqlDataReader sqlDupReader = sqlDupCmd.ExecuteReader(CommandBehavior.CloseConnection);

        if (sqlDupReader.Read())
        {
            StatusLabel.Text = "Upload status: The file already exists.";
            sqlDupReader.Close();
        }

        else
        {
            sqlDupReader.Close();

            //See "How To Use DPAPI (Machine Store) from ASP.NET" for information about securely storing connection strings.
            String sqlStmt = "Insert into Songs values (@songpath);";
            SqlConnection sqlConn = new SqlConnection(@"Data Source = .\SQLEXPRESS; AttachDbFilename = |DataDirectory|\Database.mdf; Integrated Security = True; User Instance = True; uid=sa; pwd=password;");
            SqlCommand cmd = new SqlCommand(sqlStmt, sqlConn);
            SqlParameter sqlParam = null;

            //Usage of Sql parameters also helps avoid SQL Injection attacks.
            sqlParam = cmd.Parameters.Add("@userName", SqlDbType.VarChar, 150);
            sqlParam.Value = Server.MapPath("~/Uploads/") + filename;

            //Attempt to add the song to the database.
            try
            {
                sqlConn.Open();
                cmd.ExecuteNonQuery();
                FileUploadControl.SaveAs(Server.MapPath("~/Uploads/") + filename);
                songList.Items.Add(filename);
                StatusLabel.Text = "Upload status: File uploaded!";
            }

            catch (Exception ex)
            {
                StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
            }

            finally
            {
                sqlConn.Close();
            }
        }
    }
}

But this buttonfunction provides the same results:

protected void uploadClicked(object sender, EventArgs e)
{
    StatusLabel.Text = "FooBar";
}

Has anyone had this problem before, or might know what the cause is?

Thanks!

  • 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-14T05:52:38+00:00Added an answer on May 14, 2026 at 5:52 am

    My friend helped me figure it out. It was because ASP.NET only allowed uploads of 4MB sizes. I had to go into the web.config or the machine.config file and change the value of MaxRequestLength to be larger than 4096. This solved it.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.