ASP.NET网站项目中的Web引用行为

时间:2021-05-22 05:35:09

On my local workstation, I have a Visual Studio studio that contains a .NET 3.5 C# class library project and an .NET 3.5 ASP.NET web site project.

在我的本地工作站上,我有一个Visual Studio工作室,其中包含一个.NET 3.5 C#类库项目和一个.NET 3.5 ASP.NET网站项目。

I created a web reference (example http://prod.webservices/myservice/default.asmx) in the C# class library using the "Add Web Reference" module. It created an app.config with the following section:

我使用“添加Web引用”模块在C#类库中创建了一个Web引用(例如http://prod.webservices/myservice/default.asmx)。它使用以下部分创建了一个app.config:

<applicationSettings>
    <MyCompany.MyApp.Data.Properties.Settings>
        <setting name="MyCompany_MyApp_Data_MyWebService" serializeAs="String">
            <value>http://prod.webservices/myservice/default.asmx</value>
        </setting>
    </MyCompany.MyApp.Data.Properties.Settings>
</applicationSettings>

In my ASP.NET web propject I also created a reference to the same web service using the "Add Web Reference" feature. It added the following item to the appSettings of my web.config file:

在我的ASP.NET Web项目中,我还使用“添加Web引用”功能创建了对同一Web服务的引用。它将以下项添加到我的web.config文件的appSettings中:

<add key="MyWebService.default" value="http://prod.webservices/myservice/default.asmx" />

I also created a reference to the class library file in the ASP.NET web site project. When I deployed my ASP.NET web site to our development server, I only move the web.config file not the app.config file for the class library, and all reference to the web service work.

我还在ASP.NET网站项目中创建了对类库文件的引用。当我将ASP.NET网站部署到我们的开发服务器时,我只移动web.config文件而不是类库的app.config文件,并且所有对Web服务的引用都有效。

When I try to modify the web.config file to change the web reference to http://dev.webservices/myservice/default.asmx, it still uses the prod.webservice reference URL.

当我尝试修改web.config文件以将Web引用更改为http://dev.webservices/myservice/default.asmx时,它仍然使用prod.webservice引用URL。

What do I have to do to get the development environment to use http://dev.webservice web service?

要使开发环境使用http://dev.webservice Web服务,我该怎么办?

1 个解决方案

#1


Explicitly assign the URL (by reading it from the config) after creating the proxy in your code.

在代码中创建代理后,明确分配URL(通过从配置中读取)。

#1


Explicitly assign the URL (by reading it from the config) after creating the proxy in your code.

在代码中创建代理后,明确分配URL(通过从配置中读取)。