Asked by:
.asmx HelloWorld() Not found while Invoke

Question
-
User-712926555 posted
Hi,
I am using VS2010. I am adding .asmx web service in my application.
I Have added In web.config
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>Right click myproject and click Convert to Web Application.
In .asmx
[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] [System.Web.Script.Services.ScriptService] public class AppService : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return "Hello World"; } }
While invoke still 404 not found error
Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: /HelloWorld.aspx Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
I think, Requested URL: /HelloWorld.aspx is the problem how to ignore it
Saturday, December 10, 2016 8:18 AM
All replies
-
User475983607 posted
Hisanth
I think, Requested URL: /HelloWorld.aspx is the problem how to ignore itYeah... you don't want to ignore it. you want to use the correct URL. Right click the asmx service and select "View in Browser". This will open the service in your browser, just copy the URL.
Secondly, the error is references an ASPX page. Do you have a HelloWord.aspx page?
Please take a moment to carefully review your work.
Saturday, December 10, 2016 1:57 PM -
User-2057865890 posted
Hi Hisanth,
Seems like you add web service to an existing web application and deploy it to IIS.
reference:
https://www.asp.net/mvc/overview/deployment/visual-studio-web-deployment/deploying-to-iis
Best Regards,
Chris
Monday, December 12, 2016 6:09 AM -
User-712926555 posted
I have added web reference
the Properties of localhost is
While running
If i click helloworld
If I invoke
How to solve it.
Saturday, December 17, 2016 10:06 AM -
User475983607 posted
Hisanth
How to solve it.You've done something goofy with your project. I created an empty project with just the default HelloWorld method and uncommitted the client script.
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; namespace AsmxCs { /// <summary> /// Summary description for AsmxJson /// </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 AsmxJson : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return "Hello World"; } } }
- Ran the service
- Clicked HelloWorld
- Clicked Invoke
Result
<string xmlns="http://tempuri.org/">Hello World</string>
I assume you have logic somewhere that is trying to redirect to an aspx page.
Saturday, December 17, 2016 10:26 AM -
User-712926555 posted
script services[ScriptMethod(UseHttpGet = true)]
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}But not ye solved
Saturday, December 17, 2016 10:32 AM -
User475983607 posted
Again, I created a new project added an ASMX and HelloWorld worked as expected. I don't know how to reproduce the issue you have described above.
Try creating a new ASMX project and see if the issue is still happening. Then post the steps to reproduce the issue, VS version, project template, etc.
Saturday, December 17, 2016 10:44 AM