ajaxControlToolkit AdditionalUploadFileExtensions在Web中的位置。配置文件

时间:2018-10-04 08:25:40

标签: asp.net .net web-config ajaxcontroltoolkit

我需要能够使用ajaxToolkit:AjaxFileUpload控件导入.msg文件。我读过各种文章,说我需要将以下内容添加到我的web.config文件中。

<ajaxControlToolKit additionalUploadFileExtensions="msg" />

我不确定将其放置在配置文件中的位置以及尝试添加它的位置,但会收到以下错误消息:

  

HTTP错误500.19-内部服务器错误

     

无法访问请求的页面,因为该页面的相关配置数据无效。

TIA

<?xml version="1.0" encoding="utf-8"?>

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1" />
    <sessionState mode="InProc" timeout="20" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Optimization" />
      </namespaces>
      <controls>
        <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
      <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" /></controls>
    </pages>
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
    </httpModules>
    <customErrors mode="Off"></customErrors>
    <authentication mode="Windows"></authentication>
    <httpHandlers>
      <add verb="*" path="AjaxFileUploadHandler.axd"
        type="AjaxControlToolkit.AjaxFileUploadHandler, 
          AjaxControlToolkit"/>
    </httpHandlers>
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
      </dependentAssembly>      
      <dependentAssembly>
        <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.2.1" newVersion="4.0.2.1" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <remove name="TelemetryCorrelationHttpModule" />
      <add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler" />
      <remove name="ApplicationInsightsWebTracking" />
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
    </modules>
  <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    <add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
    </handlers>
  </system.webServer>
  <connectionStrings>
  </connectionStrings>

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
      </smtp>
    </mailSettings>
  </system.net>
  <appSettings>
  </appSettings>
  <ajaxControlToolkit additionalUploadFileExtensions="msg" />

</configuration>

1 个答案:

答案 0 :(得分:0)

您需要在web.config中投放config部分:

//take the zip file from sftp
Console.WriteLine("Mendownload File va_txn dari KPFS");
            Console.WriteLine("===================================");
            string remoteDirectory = "/va/";

            using (SftpClient sftp = new SftpClient(host, port, username, password))
            {
                try
                {
                    sftp.Connect();
                    var fileIn = sftp.ListDirectory(remoteDirectory);
                    foreach (var file in fileIn)
                    {
                        if (!file.Name.Equals(".") && !file.Name.Equals("..") && file.LastWriteTime.Date == DateTime.Today)
                        {
                            Console.WriteLine(file.Name);
                            Console.WriteLine("File ditemukan, selesai dikompress");

                            //code to download file
                            using (Stream file1 = File.Create(@"C:\Users\u532246\Desktop\VA\" + file.Name))
                            {
                                sftp.DownloadFile(remoteDirectory + file.Name, file1);
                            }
                        }
                    }
                }
                catch
                {

                }
                sftp.Disconnect();
            }

            //Unzip file
            string pathzip = @"C:\Users\Desktop\VA\va_for_copartner_daily.zip";
            using (ZipFile zip = new ZipFile())
            {
                zip.ExtractAll(pathzip);
            }