harmmeijer
Programmer
This seems to be a problem with some folders but I can't find out any differences between the folders.
I have 3 files: web.config test.aspx and test.htm, test.htm contains a form with 3 text fields and a file, this is submitted to test.aspx which will list the contents of the form submitted by test.htm.
When I put the 3 files in inetpub/scripts I loose all form values after submit, the output of test.aspx is:
files count is: 0
requestform count is: 0
The request headers allso indicate that there is no content:
CONTENT_LENGTH 0
When I put the files in another folder it does work, I get the file and the form values. This only seems to be on a server where .net runtime v1.1.4322 is installed.
Here are the 3 files:
test.htm
test.aspx
web.config
Greetings, Harm Meijer
I have 3 files: web.config test.aspx and test.htm, test.htm contains a form with 3 text fields and a file, this is submitted to test.aspx which will list the contents of the form submitted by test.htm.
When I put the 3 files in inetpub/scripts I loose all form values after submit, the output of test.aspx is:
files count is: 0
requestform count is: 0
The request headers allso indicate that there is no content:
CONTENT_LENGTH 0
When I put the files in another folder it does work, I get the file and the form values. This only seems to be on a server where .net runtime v1.1.4322 is installed.
Here are the 3 files:
test.htm
Code:
<form name="frmDocument" id="frmDocument" enctype="multipart/form-data" method="post" onsubmit="doPost();" action="test.aspx">
<input type="file" name="myFile" id="myFile" />
<input type="text" value="this will be gone after submit" name="stupidName" id="stupidName" />
<input type="text" value="Xhtml has depreciated name but if I want to see any of this value in aspx (latest technology) I have to give this a name" name="sillyHa" id="sillyHa" />
<input type="text" name="uniqueURL" id="uniqueURL" />
<input type="submit" />
</form>
<script>
function doPost(){
var dte = new Date();
document.getElementById("uniqueURL").value = dte.getTime();
}
</script>
test.aspx
Code:
<%@ Page Language="vb" AutoEventWireup="true" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
dim i as int32 = 0
Dim strDestPath As String = ""
Dim sbResponse As New System.text.StringBuilder()
sbResponse.append("files count is: ")
sbResponse.append(Request.Files.count)
Do While i < Request.Files.Count
' check if the file allready exsist in the destination directory
Dim arrfileName() As String = Request.Files(i).FileName().Split("\")
Dim strFilename As String = arrfileName(arrfileName.Length - 1)
Dim arrfileExtention As String() = strFilename.Split(".")
Dim strFileExtention As String = ""
Dim strFileWithExtention As String = ""
Dim intUniqueFile As Int16 = 0
If arrfileExtention.Length > 1 Then
strFileExtention = "." & arrfileExtention(arrfileExtention.Length - 1)
ReDim Preserve arrfileExtention(arrfileExtention.Length - 2)
strFilename = Join(arrfileExtention, ".")
strFileWithExtention = strFilename & strFileExtention
Else
strFileExtention = ""
strFileWithExtention = strFilename
End If
Dim strFilepath As String = strDestPath
If strFileWithExtention = "" Then
GoTo EndOfLoop
End If
' generate the file inputs
sbResponse.Append("<br>Filename: ")
sbResponse.Append(strFilename)
sbResponse.Append("<br>filepath: ")
sbResponse.Append(strFilepath)
sbResponse.Append("<br>fileExtention: ")
sbResponse.Append(strFileExtention)
sbResponse.Append("<br>filesize: ")
sbResponse.Append(Request.Files(i).ContentLength)
EndOfLoop:
i = i + 1
Loop
' generate the rest of the inputs
sbResponse.append("<br>requestform count is: ")
sbResponse.append(Request.Form.count)
sbResponse.append("<br>")
i = 0
While i < Request.Form.Count
sbResponse.Append(Request.Form.Keys(i))
sbResponse.Append(": ")
sbResponse.Append(Request.Form.Item(i))
sbResponse.Append("<BR>")
sbResponse.Append(vbCrLf)
i = i + 1
End While
' TODO: should do something with the request.querystring if any is there
Response.Write(sbResponse.ToString)
End Sub
</script>
web.config
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<httpRuntime
maxRequestLength="65104"
/>
<compilation defaultLanguage="vb" debug="true" />
<customErrors mode="Off" />
<identity impersonate="false" />
<authentication mode="Windows" />
<authorization>
<allow users="*" />
</authorization>
<trace enabled="true" requestLimit="10" pageOutput="true" traceMode="SortByTime" localOnly="false" />
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false"
timeout="20"
/>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>
</configuration>
Greetings, Harm Meijer