繁体   English   中英

如何在URL中发送base64字符串?

[英]How to send base64 string in a url?

我有一个离子应用程序,我想通过该应用程序将base64字符串发送到WCF服务。 由于base64字符串很大,因此出现以下错误-“ HTTP错误414。请求URL太长。 ”我已在IIS上托管了此服务。 有什么办法可以使它正常工作吗? 我尝试在线搜索此问题,但没有任何方法。

这是我的方法-

 [OperationContract]
        [WebInvoke(Method = "POST",UriTemplate = "/ReportaBug?base64String={base64String}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json )]
        void ReportaBug(string base64String);

这是我的web.config文件-

 <system.web>
    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime  targetFramework="4.6.2" maxUrlLength="32768" maxQueryStringLength="32768"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0"/>
    <services>
      <service name="FusionRestService.FusionRestService" behaviorConfiguration="ServiceBehavior">
        <endpoint binding="webHttpBinding" contract="FusionRestService.IFusionRestService" behaviorConfiguration="web"></endpoint>
        <endpoint
            address="mex"
            binding="mexHttpBinding"
            contract="IMetadataExchange"/>
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <security>
      <requestFiltering>
         <requestLimits maxQueryString="32768"/>
      </requestFiltering>
    </security>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>

这是一个IIS错误,告诉您给定URL的长度超出限制。 IIS的最大URL长度由HttpRuntimeSection.MaxUrlLength属性定义。 其值是260个字符。 这可能会导致问题超出配置的maxUrlLength URL的长度,这是解决此问题的方法: https : maxUrlLength

更新我在本地主机中测试了您的代码,并且工作正常。 我刚刚在我的web.config添加了此参数

<httpRuntime targetFramework="4.6.2" maxUrlLength="32768" maxQueryStringLength="32768" />

<security>
  <requestFiltering>
    <requestLimits maxQueryString="32768"/>
  </requestFiltering>
</security>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM