2013-02-16 86 views
1

嗨,我想创建一个示例Web服务,我是新手,但是当我运行我的Web服务程序时,出现以下错误。 。其他详情如下 -HTTP错误403.14 - 禁止在Windows 7上使用Visual Studio 12创建Web服务

我的AssemblyInfo.cs

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

namespace MyFirstWebService 
{ 
    /// <summary> 
    /// Summary description for Service1 
    /// </summary> 
    [WebService(Namespace = "http://tempuri.org/")] 
    [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 Service1 : System.Web.Services.WebService 
    { 
     [WebMethod] 
     public string simpleMethod(String srt) 
     { 
      return "Hello " + srt; 
     } 

     [WebMethod] 
     public int anotherSimpleMethod(int firstNum, int secondNum) 
     { 
      return firstNum + secondNum; 
     } 

    } 
} 

当我运行此我得到

enter image description here

下面是我的Windows快照功能的服务 -

enter image description here

我的IIS设置如:

enter image description here

我跑以下命令我CMD %WINDIR%\微软.NET \ Framework \ v4.0.30319 \ aspnet_regiis.exe -ir

请告诉我如何摆脱这一点。

回答

2

看来'默认文档'(default.aspx,default.asp,index.htm等)在您的Web应用程序中不可用。 因此,作为“目录浏览”的错误未启用。 尝试打开web服务的URL,例如:http://本地主机:端口] /webservicename.aspx

希望它有助于

+0

我收到以下错误时,我给http:// localhost:50383/simpleMethod.aspx '/'应用程序中的服务器错误。 无法找到该资源。 描述:HTTP 404.您正在查找的资源(或其某个依赖项)可能已被删除,名称已更改或暂时不可用。请检查以下网址并确保它拼写正确。 请求的网址:/simpleMethod.aspx 版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.17929 你能告诉我如何把默认文件? – 2013-02-16 13:18:34

+0

谢谢你,你救了我 – JkAlombro 2017-09-28 12:19:25

0

侧面说明,要确保你有合适的启动项目集(很长一段时间,因为我调试.net:p)

相关问题