WebService in C # with 404 error

0

I'm doing maintenance on a C # project, which has WebServices. I created a new service and executed the program, it works as images below, but when calling the method it gives 404 error.

Is this a normal behavior?

Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace ServicosMegasul
{
    /// <summary>
    /// Summary description for WebService1
    /// </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 WebService1 : System.Web.Services.WebService
    {

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

Images

    
asked by anonymous 18.03.2016 / 17:20

2 answers

1

It seems that this is a common problem when using IIS 7.5.

According to this response in StackOverflow , you should add this in web.config

<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true"/>
    <handlers>
      <add verb="*" path="*.asmx" name="asmx" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </handlers>
</system.webServer>
    
14.04.2016 / 22:12
0

If you use MVC in the app_start folder in the route logger you can skip the route for your web service, it worked for me.

routes.IgnoreRoute("{resource}.asmx/{*pathInfo}");
    
08.06.2018 / 17:07