Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The original file is in the temp folder error when uploading a file to IIS server from asp.net web forms project

I am trying to upload some files wtih different extensions like .png,.jpg,.txt,.pdf etc. to IIS server .However my all files are created to given path but they are all 1kb size and when you open them it says

The original file is in the temp folder. Full path of the file: C:\Temp\xxxxxxxxx.tmp

My code works perfectly on localhost when running from the source code and There is no such a folder on web server's directory like mentioned in the message.

My code:

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
                <asp:FileUpload ID="FileUpload1"  Multiple="Multiple" name="okantestfileupload" runat="server" />
                <asp:Button ID="btnFileUpload" OnClick="btnFileUpload_Clickk" runat="server" Text="ekle" Width="150px" CssClass="CommandButton" />
               <asp:ListBox runat="server" ID="ListBoxForInfo" Width="400" CssClass="NormaltextBox" ></asp:ListBox>
        </div>
    </form>
</body>
</html>

.cs part

protected void btnFileUpload_Clickk(object sender, EventArgs e)
    {
        string strFolder = @"D:\TEST\";
        HttpFileCollection uploadedFiles = Request.Files;

        for (int i = 0; i < uploadedFiles.Count; i++)
        {
            HttpPostedFile uploadedFile = Request.Files.Get(i);


            var uFileSize = uploadedFile.ContentLength;
            var uFileName = uploadedFile.FileName;
            var uContentType = uploadedFile.ContentType;
            string uExtension =
               System.IO.Path.GetExtension(uploadedFile.FileName);

            uploadedFile.SaveAs(strFolder + uFileName);
            ListBoxForInfo.Items.Insert(0, uFileName + "." + uContentType + " Boyut: (" + uFileSize + " bytes)  yüklendi.");


        }
    }

What should I do to fix that?I have already tried some solutions including taking consideration of antivirus programmes.

Regards

like image 255
SophisticatedUndoing Avatar asked Sep 02 '25 03:09

SophisticatedUndoing


1 Answers

The problem was the Managed Pipeline Mode configuration of the related Application Pool.The application was run on v2.0 .NET CLR Version but the project was built on .NET 3.5. So changing the Managed PipeLine Mode from Classic to Integrated solved the problem unintentionally without knowing the detailed mechanism. Probable incompatibilities may occur at other external components used in the project.The full cycle test is being performed right now but the upload problem has been fixed.

like image 110
SophisticatedUndoing Avatar answered Sep 04 '25 23:09

SophisticatedUndoing