Reputation: 173
A new, empty Visualstudio project, with only auto-generated code, throws an exception, when trying to call the webservice, from that webservices own description page.
I had this weird problem, that I project, that worked fine, when I used it last time, suddenly stopped working (no change in between) when I opened it 2 Months later. I couldn't figure out, what the cause was, so I tryed to recreate it in a simpler fassion.
This is the not working example, without a single line of handwritten code, all created by visualstudio.
Here's what I did to recreate the problem.
I use Visualstudio 2015 I created a new Project -> Web -> ASP.NET -> Web API. I added a empty folder, called "services" I Rightclicked on the folder -> Add -> (Webservice Asmx)
a new demopage was created:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace ProjektName.Services
{
/// <summary>
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// [System.Web.Script.Services.ScriptService]
public class getUrl : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
when I start call the page, the Webservice self description page opens.
These are not actual screenshots because my Visual Studio is in a different language. (They are just used to explain my point).
I use windows 10 and use the lates Chrome and firefox browsers. /HelloWorld_files/image004.jpg
Now, when I hit the button, I get a "Server Error in '/' Application." "The resource cannot be found."
The error message looks something like this: https://www.1and1.com/cloud-community/fileadmin/community/Screenshots/How_to_Fix_the_Error_in_application_Windows_Server_error/404.jpg
I haven't written a single line of code, it was all generated by Visal Studio. If I give the project to a coworker, it doesn't work on his pc as well.
What do I miss?
Upvotes: 1
Views: 41
Reputation: 273179
Add an ignore rule:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("Services/{resource}.asmx/{*pathInfo}"); // add this line
....
}
But it looks like you are doing something 'Tutorial'. Are you sure you want to invest in ASMX technology?
Upvotes: 1