C# 我在IIS上托管了一个带有实体框架的ASP.NET web服务,如何使用ip访问它?

C# 我在IIS上托管了一个带有实体框架的ASP.NET web服务,如何使用ip访问它?,c#,asp.net,entity-framework,iis,C#,Asp.net,Entity Framework,Iis,我在IIS上托管了一个ASP.NET web服务。但我无法使用ip访问它 例如:如果在同一设备的浏览器中键入设备ip,则无法访问该设备。在IIS中,当我使用localhost作为主机名时,web服务是可以访问的,但我无法访问数据库 我附上了一个屏幕截图,它显示了访问访问数据库的web服务中的一个方法时的错误消息 这是我的web.config: 您可以将网站发布到IIS上的默认网站 如果不存在,您可以执行以下操作: 将网站名称更改为默认网站 将应用程序池设置为默认值 确保站点的路径位于inetpu

我在IIS上托管了一个ASP.NET web服务。但我无法使用ip访问它

例如:如果在同一设备的浏览器中键入设备ip,则无法访问该设备。在IIS中,当我使用localhost作为主机名时,web服务是可以访问的,但我无法访问数据库

我附上了一个屏幕截图,它显示了访问访问数据库的web服务中的一个方法时的错误消息

这是我的web.config:


您可以将网站发布到IIS上的默认网站

如果不存在,您可以执行以下操作:

将网站名称更改为默认网站 将应用程序池设置为默认值 确保站点的路径位于inetpub\wwwroot
检查是否发现类似“;服务器';在抛出错误的方法的文件和代码上?顺便说一句,最简单的方法是在方法中设置一个断点,然后在调试程序中逐步执行。初学者很容易忽略这样一个事实,即IIS站点绑定可以控制您在浏览器中使用的URL,运行报告并了解详细信息。如果站点绑定不接受带有IP地址的URL,请改用正确的URL,或者相应地编辑绑定。我已经这样做了。我的托管文件仅在此路径上。仅当在iis中创建站点时,我将主机名保留为localhost,如果我保留其他名称,它将不会浏览。在本地主机中,我也无法访问数据库。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <section name="entityFramework" 
                 type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </configSections>
    <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    </appSettings>
    <system.web>
        <compilation debug="true" targetFramework="4.6.1" />
        <httpRuntime targetFramework="4.6.1" />
    </system.web>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior>
                    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
        <directoryBrowse enabled="true" />
    </system.webServer>
    <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
        <providers>
            <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
    </entityFramework>
    <connectionStrings>
        <add name="Chromoscan2Entities"  
             connectionString="metadata=res://*/CytoModel.csdl|res://*/CytoModel.ssdl|res://*/CytoModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=WIN10D-02198;initial catalog=Chromoscan2;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
             providerName="System.Data.EntityClient" />
    </connectionStrings>
</configuration>