我在网站项目中创建了一个Web服务(在vs 2010中)。在 Visual Studio 中,当我运行此网站时,我可以看到此 Web 服务,如下所示:
网络服务的主体是:
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {
public WebService () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public int Plus(int x, int y)
{
return x + y;
}
[WebMethod]
public int Multiply(int x, int y)
{
return x * y;
}
}
我通过以下步骤在 iis 6 上托管此网站:
1) 右键单击“网站”节点,单击“添加新网站”选项 IIS。
2) 为其分配端口(对于 ex 1919 端口)
3) 下一步指定网站的物理路径
4) 指定访问级别权限
5)完成
现在我想调用以下地址,并给出此错误:
我重新启动了iis,但没有发生任何事情。
我想在本地使用这个网络服务,为什么会发生这个错误?怎么解决?
最佳答案
创建虚拟目录时选中“执行(例如ISAPI应用程序或CGI)”复选框
关于c# - 无法在 iis 上托管 ASMX Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16808137/