1

C# から" http://localhost:8733/SmgService/ " である app.config ファイルで指定されたベースアドレスを取得したいと思います。

Microsoft のドキュメントを調べましたが、現在、C# コード ビハインドからこの baseAddress にアクセスする方法がわかりません。どんな助けでも大歓迎です。

 <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
          <add key="aspnet:UseTaskFriendlySynchronizationContext"value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" />
      </system.web>
      <system.serviceModel>
        <services>
              <service name="SmgService.PrintService">
                <host>
                  <baseAddresses>
                    <add baseAddress = "http://localhost:8733/SmgService/"/><!--i need this address-->
                  </baseAddresses>
                </host>
                <endpoint address="" binding="basicHttpBinding" contract="SmgService.IPrintService">
                  <identity>
                    <dns value="localhost"/>
                  </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
              </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
  </system.serviceModel>

</configuration>
4

1 に答える 1