我用Entity Framework在IIS中托管了我的ASP.NET Web服务,但无法从外部访问它
我使用实体框架开发了一个web服务。当我通过IIS托管web服务,但无法访问它时。在localhost上,它工作正常 我已尝试从SQLServerManagementStudio授予访问权限。尝试Windows身份验证和SQL Server身份验证。不知道怎么了。另外,还尝试在我用Entity Framework在IIS中托管了我的ASP.NET Web服务,但无法从外部访问它,asp.net,iis,Asp.net,Iis,我使用实体框架开发了一个web服务。当我通过IIS托管web服务,但无法访问它时。在localhost上,它工作正常 我已尝试从SQLServerManagementStudio授予访问权限。尝试Windows身份验证和SQL Server身份验证。不知道怎么了。另外,还尝试在web.config文件中进行更改 这是我的web.config文件: <?xml version="1.0" encoding="utf-8"?> <configuration> <
web.config
文件中进行更改
这是我的web.config
文件:
<?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="data source=WIN10D-02198;initial catalog=Chromoscan2;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
您遇到了什么错误?“外面”是指互联网吗?您是说通过浏览器访问您的web应用程序,还是说您的web应用程序无法访问数据库?当我将主机名指定为localhost时。我可以浏览。但如果我给ex:cyto起了其他名字,我会得到错误,因为“无法访问此页面”。通过外部方式从ohter设备访问。是的,当我从iis上的设备托管Web服务时,我指的是通过浏览器从其他设备访问我的Web服务。如果我们指的是浏览,那么SQL Server在此阶段是不相关的。如果您想从internet浏览名为cyto
的主机,则需要购买该主机名并向internet DNS公司注册。你做到了吗?您是否已在路由器中打开计算机的端口80(或正在运行的任何端口)?我在这里做了很多假设。你需要提供更多信息。我不能只从我的设备上托管它。我会在我的设备上运行此服务,如果有人想通过外部访问它。他们可以使用我的设备ip:url访问。是否可以使用此方法?如果我错了,请纠正我。是的,您可以使用IP地址,但您需要使用面向internet的路由器的IP地址,并且您必须告诉路由器,web端口(通常是端口80)上的任何传入请求都需要定向到您的设备。您还需要确保您的ISP不会阻止此类活动。您的设备如何连接到internet?