0

In asp.net I tried making an application in which I have a file upload option ...user can uplaod 500 files of image types in 1 go(select multiple image types files by using ctrl)....bt now when i have deployed this in IIS....its not working....displays a message page cannot be found....in web config i have increased attributes of maxRequestLength and executionTimeout.....Kindly help

2
Contributors
5
Replies
19
Views
4 Years
Discussion Span
Last Post by JorgeM
0

A page cannot be found error (404) means that that are most likely trying to access the wrong URL or path.

Go back and check on that. We don't know for sure because we would need to see your relevant code.

0
FRONT END CODE:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="File.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>FILE UPLOAD</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   <table width="100%" style="background-color:#ffa500;">
           <tr style="background-color:#ffa500; height:70px">
               <td  style="border-collapse:collapse" width="40%">
                   <img src="ipru-logo.gif" alt=""/>
               </td>
               <td colspan="2" width="100%" align="left" style="font-family:Zurich BT; border-collapse:collapse; font-weight:bold; color:White; font-size:x-large">
                File Upload Application

               </td>
           </tr>

       </table>  
       <table width="100%">
     <tr style="height:70px" align="center" >
           <td style="border-collapse:collapse" width="100%" align="center" colspan="2">
            <asp:FileUpload ID="fileupload" runat="server" multiple="multiple" />
           </td>
           </tr>
           <tr>
           <td style="border-collapse:collapse" width="100%" align="center" colspan="2">
           <asp:Button runat="server" ID="btnUpload" Text="Upload" 
        onclick="btnUpload_Click"  /> 
        </td>
           </tr>
    </table>


    </div>
    </form>
</body>
</html>



CODE BEHIND



using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    int uploadCount = 0;
    int notUploadCount = 0;
    string cn1 = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ToString();
    protected void Page_Load(object sender, EventArgs e)
    {
        AuthUser();
    }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        try
        {
            int count = Request.Files.Count;
            if (fileupload.HasFile)
            {
                for (int i = 0; i < Request.Files.Count; i++)
                {
                    HttpPostedFile hpf = Request.Files[i];
                    string filename = hpf.FileName;
                    string FileExtension = filename.Substring(filename.LastIndexOf('.') + 1).ToLower();
                    if (FileExtension.ToLower() == "jpg" || FileExtension.ToLower()== "jpeg")
                    {

                       // D:\\D drive backup\\Vaishali\\
                        hpf.SaveAs("D:\\D drive backup\\Destination_Folder\\" + filename);
                        uploadCount++;
                    }
                    else
                    {
                        notUploadCount++;

                    }

                }
            }
            else
            {
                Response.Write("<script language=javascript>alert('Please Select a file');</script>");
            }
            string message="";
            string message1 = "";
            if (uploadCount > 0)
                message = message + uploadCount + " files have been saved sucessfully. " ;
            if (notUploadCount > 0)
                message1 =  message1 + notUploadCount + " files could not be uploaded because it does not belong to the image format.";
            //message = lblMsg.Text;
            Response.Write("<script language=javascript>alert('"+message+" \\n "+message1+"');</script>");
        }
        catch (Exception e1)
        {
            Response.Write(e1.Message);
        }

    }

My Code

0

Your code is working. All i did was copy your code and paste it to a new page on my test IIS server, not visual studio dev server.

All i had to do is update this line of code:
hpf.SaveAs("D:\\D drive backup\\Destination_Folder\\" + filename);

and of course remove the code you have in your page load subroutine.

It worked without any issues was so-ever. no 404 errors, i uploaded multiple jpg files.

Where/when/what are you doing when you see the page cannot be found error?

0

for nearly around 30 fiels it is working.....bt it is not working for 500 jpg files....try it for upload of 500 jpg files

0

If its working for at least 2, then we know that the basic functionality of the multiple upload works.

Where and when do you get a page not found error?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.