FileUpload.HasFile 属性不在 UpdatePanel 内,但仍然始终返回 false
我遇到这个问题几天了,在谷歌上搜索后仍然没有帮助。有谁帮忙解决一下。我的 fileupload 控件未放置在 updatepanel 中,但它的 hasFile 属性仍然始终返回 false。
这是我的代码
<table style="width: 100%;">
<tr>
<td style="width: 200px;">
Name
</td>
<td style="vertical-align: top;">
<div style="float: left;">
<asp:TextBox ID="txtName" runat="server" Width="500px" CssClass="text01" />
</div>
<div style="float: left; padding: 2px 0 0 5px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" CssClass="error01"
ErrorMessage="This field is required !" Display="Dynamic" ControlToValidate="txtName"></asp:RequiredFieldValidator>
</div>
</td>
</tr>
<tr>
<td style="width: 200px;">
Position
</td>
<td style="vertical-align: top;">
<div style="float: left;">
<asp:TextBox ID="txtPosition" runat="server" Width="500px" CssClass="text01" />
</div>
<div style="float: left; padding: 2px 0 0 5px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" CssClass="error01"
ErrorMessage="This field is required !" Display="Dynamic" ControlToValidate="txtPosition"></asp:RequiredFieldValidator>
</div>
</td>
</tr>
<tr>
<td>
Vietnamese Position
</td>
<td>
<div style="float: left;">
<asp:TextBox ID="txtPositionVN" runat="server" Width="500px" CssClass="text01" />
</div>
<div style="float: left; padding: 2px 0 0 5px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" CssClass="error01"
ErrorMessage="This field is required !" Display="Dynamic" ControlToValidate="txtPositionVN"></asp:RequiredFieldValidator>
</div>
</td>
</tr>
<tr>
<td>
Order
</td>
<td>
<asp:DropDownList ID="ddlOrder" runat="server" Height="16px" Width="150px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 200px;">
Email
</td>
<td style="vertical-align: top;">
<div style="float: left;">
<asp:TextBox ID="txtEmail" runat="server" Width="500px" CssClass="text01" />
</div>
<div style="float: left; padding: 2px 0 0 5px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" CssClass="error01"
ErrorMessage="This field is required !" Display="Dynamic" ControlToValidate="txtEmail"></asp:RequiredFieldValidator>
</div>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtEmail" CssClass="text01" Display="Dynamic"
ErrorMessage="Input valid email address !"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td style="width: 200px;">
Mobile Phone Number
</td>
<td style="vertical-align: top;">
<div style="float: left;">
<asp:TextBox ID="txtPhone" runat="server" Width="500px" CssClass="text01" />
</div>
<div style="float: left; padding: 2px 0 0 5px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" CssClass="error01"
ErrorMessage="This field is required !" Display="Dynamic" ControlToValidate="txtPhone"></asp:RequiredFieldValidator>
</div>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ControlToValidate="txtPhone" CssClass="text01" Display="Dynamic"
ErrorMessage="Input valid mobile phone number !" ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td style="width: 200px;vertical-align: top;">
Address
</td>
<td style="vertical-align: top;">
<div style="float: left;">
<asp:TextBox ID="txtAdd" runat="server" Width="500px" CssClass="text01" TextMode="MultiLine" Height="200px" />
</div>
</td>
</tr>
<tr>
<td style="vertical-align: top;">
Image
</td>
<td valign="top">
<asp:FileUpload ID="fupImage" runat="server" CssClass="text01" Width="400px" />
<asp:Image ID="imgURL" runat="server" Width="100px" Height="100px" Visible="false" />
<asp:Label ID="lblMessageForfupImage" runat="server" ForeColor="Red" Visible="false"></asp:Label>
</td>
</tr>
<tr>
<td />
<td>
<asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" CssClass="text01" />
<asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click"
CssClass="text01" Visible="False" />
<asp:Button ID="btnReset" runat="server" Text="Reset" OnClick="btnReset_Click"
CssClass="text01" CausesValidation="False" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click"
CssClass="text01" Height="22px" CausesValidation="False" />
</td>
</tr>
</table>
和隐藏代码:
if (fupImage.PostedFile.FileName != "")
{
if (!Utitlties.Instance.CheckImageFileType(fupImage.PostedFile.FileName))
{
lblMessageForfupImage.Visible = true;
lblMessageForfupImage.Text = "Image file only accept *.jpg, *.png, *.bmp, *.gif Extensions !";
fupImage.Focus();
}
else
{
evt.ImageURL = Utils.Instance.SaveImage(fupImage.PostedFile.InputStream, fupImage.PostedFile.FileName, true);
UniqueDesign.Utilities.Utitlties.Instance.DeleteFile(imgURL.ImageUrl);
}
}
当我调试它时,它的 HasFile 属性返回始终为 false,并且
fupImage.PostedFile.ContentLength = -2 但它仍然有文件名和文件类型。
这是我的 web.config :
<?xml version="1.0"?>
Visual Studio 中的 Asp.Net 配置选项。 设置和注释的完整列表可以在 machine.config.comments 通常位于 \Windows\Microsoft.Net\Framework\vx.x\Config -->
</appSettings>
<connectionStrings/>
<!--<location path="admin_ServicesPhotosManager.aspx">
<system.web>
<httpRuntime executionTimeout="3600" maxRequestLength="40960" useFullyQualifiedRedirectUrl="false"/>
</system.web>
</location>-->
<system.web>
<httpRuntime executionTimeout="3600"
maxRequestLength="40960"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="5000"
enableKernelOutputCache="true"
enableVersionHeader="true"
requireRootedSaveAsPath="true"
enable="true"
shutdownTimeout="90"
delayNotificationTimeout="5"
waitChangeNotification="0"
maxWaitChangeNotification="0"
enableHeaderChecking="true"
sendCacheControlHeader="true"
apartmentThreading="false"/>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="FileUploadLibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=AF961ECE0B692DFB"/>
</assemblies>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode="Never" enableViewStateMac="false">
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
<add verb="GET" type="darrenjohnstone.net.FileUpload.UploadProgressHandler, fileuploadlibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af961ece0b692dfb" path="UploadProgress.ashx"/>
<add verb="GET" type="darrenjohnstone.net.FileUpload.SQLFileDownloadHandler, fileuploadlibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af961ece0b692dfb" path="DownloadFile.ashx"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="upload_module" type="darrenjohnstone.net.FileUpload.UploadModule, fileuploadlibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af961ece0b692dfb"/>
</httpModules>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="OptionInfer" value="true"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824">
</requestLimits>
</requestFiltering>
</security>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<remove name="upload_module" />
<add name="upload_module" type="darrenjohnstone.net.FileUpload.UploadModule, fileuploadlibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af961ece0b692dfb" />
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="UploadProgress" verb="GET" type="darrenjohnstone.net.FileUpload.UploadProgressHandler, fileuploadlibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af961ece0b692dfb" path="UploadProgress.ashx" />
<add name="FileDownload" verb="GET" type="darrenjohnstone.net.FileUpload.SQLFileDownloadHandler, fileuploadlibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af961ece0b692dfb" path="DownloadFile.ashx" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
I face this problem for a few day, after searching on google is still not help. Anyone help fix it. my fileupload control is not placed in updatepanel but it' hasFile properties still alway return false.
Here is my code
<table style="width: 100%;">
<tr>
<td style="width: 200px;">
Name
</td>
<td style="vertical-align: top;">
<div style="float: left;">
<asp:TextBox ID="txtName" runat="server" Width="500px" CssClass="text01" />
</div>
<div style="float: left; padding: 2px 0 0 5px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" CssClass="error01"
ErrorMessage="This field is required !" Display="Dynamic" ControlToValidate="txtName"></asp:RequiredFieldValidator>
</div>
</td>
</tr>
<tr>
<td style="width: 200px;">
Position
</td>
<td style="vertical-align: top;">
<div style="float: left;">
<asp:TextBox ID="txtPosition" runat="server" Width="500px" CssClass="text01" />
</div>
<div style="float: left; padding: 2px 0 0 5px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" CssClass="error01"
ErrorMessage="This field is required !" Display="Dynamic" ControlToValidate="txtPosition"></asp:RequiredFieldValidator>
</div>
</td>
</tr>
<tr>
<td>
Vietnamese Position
</td>
<td>
<div style="float: left;">
<asp:TextBox ID="txtPositionVN" runat="server" Width="500px" CssClass="text01" />
</div>
<div style="float: left; padding: 2px 0 0 5px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" CssClass="error01"
ErrorMessage="This field is required !" Display="Dynamic" ControlToValidate="txtPositionVN"></asp:RequiredFieldValidator>
</div>
</td>
</tr>
<tr>
<td>
Order
</td>
<td>
<asp:DropDownList ID="ddlOrder" runat="server" Height="16px" Width="150px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 200px;">
Email
</td>
<td style="vertical-align: top;">
<div style="float: left;">
<asp:TextBox ID="txtEmail" runat="server" Width="500px" CssClass="text01" />
</div>
<div style="float: left; padding: 2px 0 0 5px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" CssClass="error01"
ErrorMessage="This field is required !" Display="Dynamic" ControlToValidate="txtEmail"></asp:RequiredFieldValidator>
</div>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtEmail" CssClass="text01" Display="Dynamic"
ErrorMessage="Input valid email address !"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td style="width: 200px;">
Mobile Phone Number
</td>
<td style="vertical-align: top;">
<div style="float: left;">
<asp:TextBox ID="txtPhone" runat="server" Width="500px" CssClass="text01" />
</div>
<div style="float: left; padding: 2px 0 0 5px;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" CssClass="error01"
ErrorMessage="This field is required !" Display="Dynamic" ControlToValidate="txtPhone"></asp:RequiredFieldValidator>
</div>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ControlToValidate="txtPhone" CssClass="text01" Display="Dynamic"
ErrorMessage="Input valid mobile phone number !" ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td style="width: 200px;vertical-align: top;">
Address
</td>
<td style="vertical-align: top;">
<div style="float: left;">
<asp:TextBox ID="txtAdd" runat="server" Width="500px" CssClass="text01" TextMode="MultiLine" Height="200px" />
</div>
</td>
</tr>
<tr>
<td style="vertical-align: top;">
Image
</td>
<td valign="top">
<asp:FileUpload ID="fupImage" runat="server" CssClass="text01" Width="400px" />
<asp:Image ID="imgURL" runat="server" Width="100px" Height="100px" Visible="false" />
<asp:Label ID="lblMessageForfupImage" runat="server" ForeColor="Red" Visible="false"></asp:Label>
</td>
</tr>
<tr>
<td />
<td>
<asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" CssClass="text01" />
<asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click"
CssClass="text01" Visible="False" />
<asp:Button ID="btnReset" runat="server" Text="Reset" OnClick="btnReset_Click"
CssClass="text01" CausesValidation="False" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click"
CssClass="text01" Height="22px" CausesValidation="False" />
</td>
</tr>
</table>
And Code Behind :
if (fupImage.PostedFile.FileName != "")
{
if (!Utitlties.Instance.CheckImageFileType(fupImage.PostedFile.FileName))
{
lblMessageForfupImage.Visible = true;
lblMessageForfupImage.Text = "Image file only accept *.jpg, *.png, *.bmp, *.gif Extensions !";
fupImage.Focus();
}
else
{
evt.ImageURL = Utils.Instance.SaveImage(fupImage.PostedFile.InputStream, fupImage.PostedFile.FileName, true);
UniqueDesign.Utilities.Utitlties.Instance.DeleteFile(imgURL.ImageUrl);
}
}
when i debbuged it, it's HasFile properties return alway is false, and
fupImage.PostedFile.ContentLength = -2 but it still got filename and filetype.
And here is my web.config :
<?xml version="1.0"?>
Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\vx.x\Config
-->
</appSettings>
<connectionStrings/>
<!--<location path="admin_ServicesPhotosManager.aspx">
<system.web>
<httpRuntime executionTimeout="3600" maxRequestLength="40960" useFullyQualifiedRedirectUrl="false"/>
</system.web>
</location>-->
<system.web>
<httpRuntime executionTimeout="3600"
maxRequestLength="40960"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="5000"
enableKernelOutputCache="true"
enableVersionHeader="true"
requireRootedSaveAsPath="true"
enable="true"
shutdownTimeout="90"
delayNotificationTimeout="5"
waitChangeNotification="0"
maxWaitChangeNotification="0"
enableHeaderChecking="true"
sendCacheControlHeader="true"
apartmentThreading="false"/>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="FileUploadLibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=AF961ECE0B692DFB"/>
</assemblies>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode="Never" enableViewStateMac="false">
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
<add verb="GET" type="darrenjohnstone.net.FileUpload.UploadProgressHandler, fileuploadlibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af961ece0b692dfb" path="UploadProgress.ashx"/>
<add verb="GET" type="darrenjohnstone.net.FileUpload.SQLFileDownloadHandler, fileuploadlibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af961ece0b692dfb" path="DownloadFile.ashx"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="upload_module" type="darrenjohnstone.net.FileUpload.UploadModule, fileuploadlibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af961ece0b692dfb"/>
</httpModules>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="OptionInfer" value="true"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824">
</requestLimits>
</requestFiltering>
</security>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<remove name="upload_module" />
<add name="upload_module" type="darrenjohnstone.net.FileUpload.UploadModule, fileuploadlibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af961ece0b692dfb" />
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="UploadProgress" verb="GET" type="darrenjohnstone.net.FileUpload.UploadProgressHandler, fileuploadlibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af961ece0b692dfb" path="UploadProgress.ashx" />
<add name="FileDownload" verb="GET" type="darrenjohnstone.net.FileUpload.SQLFileDownloadHandler, fileuploadlibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af961ece0b692dfb" path="DownloadFile.ashx" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding appliesTo="v2.0.50727" xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当我遇到这个问题时,我遇到了这个问题,并认为我也应该发布我的问题和解决方案。
确保您尝试上传的文件大于 0 字节。我尝试上传一些空白文本文件进行测试,每个文件的
FileName
属性设置正确,但HasFile
始终为 false。向文件添加一些文本为其提供了一些内容,并且文件能够成功上传。I came across this question when I had this problem and figured I'd post what my problem and solution were as well.
Make sure the file you are trying to upload is larger than 0 bytes. I was trying to upload some blank text files for testing and each file had the
FileName
property set correctly, butHasFile
was always false. Adding some text to the files gave it some content and the file was able to be uploaded successfully.那么你的UpdatePanel到底在哪里呢?您是否正在尝试提交位于更新面板内的表单,但也有一个不在更新面板内的文件上传控件?
我认为这也行不通。
您可以使用FileUpload的AJAX控制工具包版本,或者使用其他东西,例如Uploadify,它是一个jquery插件。
Where exactly is your UpdatePanel then? Are you trying to submit a form that is within an updatepanel, but also has a fileupload control which is not?
I don't think that will work either.
You can use the AJAX control toolkit version of FileUpload, or use something else such as Uploadify which is a jquery plugin.