简体   繁体   中英

How do I convert a ASP.NET method to ASP.NET .asmx web service

I have following asp.net method which I want to convert it into .asmx web service. How I can do that. Any help please.

public ActionResult AddCpty(string Id, string Type)
{
    //code for Addcp
    return result;
}

I am trying to convert it by putting a [WebMethod] attribute on the top of the method.

[WebMethod]
public ActionResult AddCpty(string Id, string Type)
{
    //code for Addcp
    return result;
}

Try with static

[WebMethod] 
public static ActionResult AddCpty(string Id, string Type) { 
//code for Addcp return result; 
}

Assuming you're trying to access it from within the ASP template, maybe you haven't registered the route?

See this link and find wherever your routes are being registered in your project to expose the method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM