问题描述
|
我是.NET的新手。现在,我正在尝试制作我的第一个ASP.NET Web服务。
我创建ASP.NET Web服务项目,并使用Visual Studio 2010生成的默认Web方法。
我在Visual Studio中测试了此服务,效果很好。
然后我在IIS上添加了虚拟目录,目录名为test。我使用Windows Server 2003 Standard。
并尝试通过本地主机访问Web服务。
http://localhost/test/Service1.asmx
我收到此错误消息:
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button,or try again later.
--------------------------------------------------------------------------------
A name was started with an invalid character. Error processing resource \'http://localhost/w/Service1.asmx\'. Line 1,Positi...
<%@ WebService Language=\"C#\" CodeBehind=\"Service1.asmx.cs\" Class=\"WebService1.Service1\" %>
-^
我检查了以下文件:
服务1.asmx
<%@ WebService Language=\"C#\" CodeBehind=\"Service1.asmx.cs\" Class=\"WebService1.Service1\" %>
Service1.asmx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace WebService1
{
/// <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 HelloWorld()
{
return \"Hello World\";
}
}
}
有什么不好的?感谢您的支持。
解决方法
看起来IIS计算机上未启用ASP.NET。
您可能需要检查Windows组件
control panel -> Programs and Features -> Turn Windows features on or off
,并检查运行IIS的计算机上是否已启用Internet Information Services/World Wide Web Services/Application Development Features/ASP.NET
功能,如果未启用,请检查以安装它。
, 尝试运行C:\\ WINDOWS \\ Microsoft.NET \\ Framework \\ v2.0.50727中找到的aspnet regiis实用程序命令
文件夹。也许脚本映射没有正确更新。如果您已经安装了IIS,是否在安装.NET Framework之后安装了IIS?
aspnet_regiis -i