2016-08-21 78 views
0

我是在ASP.net中创建Web应用程序的新手。我正在尝试创建简单的Web服务计算器,该计算器添加了两个数字。但是,当我调用,它给了我一个错误:如何选择ASP.NET选项卡(在IIS中)为Web应用程序选择的正确版本的.NET框架?

The resource cannot be found. 

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /CalculatorWebService.asmx/Add 
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1073.0 

为了解决它,我要确保我在ASP.NET选项卡选择时(IIS)的.NET Framework的正确版本这个应用程序。所以,我要去IIS管理器 - >查看应用程序池,这是我看到: enter image description here

我在一个正确的方式吗? 我应该选择哪一个?

我做错了什么?根据YouTube视频我做了什么: enter image description here

这里是我在VS代码:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Services; 

namespace MyWebApplication1 
{ 
    /// <summary> 
    /// Summary description for CalculatorWebService 
    /// </summary> 
    [WebService(Namespace = "http://calculatorwebservice.com/")] 
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
    [System.ComponentModel.ToolboxItem(false)] 
    // 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 CalculatorWebService : System.Web.Services.WebService 
    { 

     [WebMethod] 
     public int Add(int firstNumber, int secondNumber) 
     { 
      return firstNumber+secondNumber; 
     } 
    } 
} 

回答

0

别看那呢。您的应用程序文件夹未绑定在IIS中。换句话说,你必须在IIS中创建一个应用程序,指定子URL(http://localhost/myapp)和文件路径到物理目录。

+0

有没有这样做的例子? – Oleg

+0

@Oleg试试这个。 https://www.youtube.com/watch?v=IwbKquNBNgQ – doker

+0

还有更多的事情。你最好的选择是4.0版本......(有两个选择2.0和4.0)以及大多数时候的综合管线。 – doker

相关问题