【问题标题】:How do I deploy ASP.NET boilerplate WebApi class library as a stand-alone web service?如何将 ASP.NET 样板 WebApi 类库部署为独立的 Web 服务?
【发布时间】:2015-10-03 16:33:26
【问题描述】:

我是第一次使用 ASP.NET 样板。我已经能够成功应用 ApplicationName.CoreApplicationName.ApplicationApplicationName.ORM (NHibernate) 库。

但是,我需要将我的应用程序服务作为 Web 服务提供。我的理解是,一旦我将名为 ApplicationName.WebApi 的库部署为 IIS 的 Web 应用程序,我就会自动拥有一个 Web 服务,它通过 /api/services/ 公开我的应用程序服务。

当我这样做时,当我尝试通过浏览器向 API 发出请求时,我不断收到错误 404.0,如下所示:

我需要一些关于我到底哪里出错的建议。我的想法是我可能需要在应用程序的 web.config 中添加一些额外的配置。

目前的配置如下:

<?xml version="1.0" encoding="utf-8"?>
<configuration>  
  <connectionStrings>
    <add name="Default" connectionString="***" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Http.WebHost" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.34.0" newVersion="1.0.34.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="AutoMapper" publicKeyToken="be96cd2c38ef1005" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.webServer> <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
        <handlers>
            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
            <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
  </system.webServer>
</configuration>

感谢您的帮助。

【问题讨论】:

    标签: c# asp.net nhibernate asp.net-web-api asp.net-boilerplate


    【解决方案1】:

    您需要部署 ApplicationName.Web。 ApplicationName.WebApi 是一个类库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-15
      • 2012-07-18
      • 2010-11-09
      • 2012-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多