I am newbie in .NET. Now I am trying make my first ASP.NET Web Service.
I create ASP.NET Web Service Project and use default Web Methods generated by Visual Studio 2010.
I tested this service in Visual Studio, it works good.
Then I added virtual directory on IIS, directory name is test. I use Windows Server 2003 Standard.
And tried access to web service via localhost.
http://localhost/test/Service1.asmx
I got this error message:
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" %>
-^
I checked this files:
Service1.asmx
<%@ WebService Language="C#" CodeBehind="Service1.asmx.cs" Class="WebService1.Service1" %>
Service1.asmx.cs
using System;
using System.Coll开发者_如何学运维ections.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";
}
}
}
What can be bad? Thank for support.
Looks like ASP.NET is not enabled on the IIS machine.
You might want to check your windows components control panel -> Programs and Features -> Turn Windows features on or off
and check if the Internet Information Services/World Wide Web Services/Application Development Features/ASP.NET
feature is enabled on the machine running IIS and check to install it if it's not enabled.
.Try running aspnet regiis utility command found in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 folder.Maybe script maps not updated correctly.If you already have IIS installed,Did you installed IIS after installing .NET framework?
aspnet_regiis -i
精彩评论