In ASP.NET Application,I can't add a local webmethod to my project preferences

Kwrister 96 Reputation points
2020-12-29T04:50:04.737+00:00

First, I create a default Web Service(ASMX).And It has a default webMethod.just like:
public class WebService1 : System.Web.Services.WebService
{

    [WebMethod]  
    public string HelloWorld()  
    {  
        return "Hello World";  
    }  
}  

Next,I want to add this method to my objects's references, but it show some errors:
51864-%E6%8D%95%E8%8E%B7.png

and the detail is
51887-%E6%8D%95%E8%8E%B72.png

I don't konw why.
Please help me.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,815 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kwrister 96 Reputation points
    2020-12-29T05:43:56.12+00:00

    I finde the reason.
    Because I webMethod in App_Code Files,So it can't be called.
    if I move it to another place, it work success!

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.