Webservice in C# with 404 error

Asked

Viewed 897 times

0

I’m doing maintenance on a C Project, which has Webservices. I created a new service and ran the program, it works as images below, but calling the method gives error 404.

This is 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";
        }
    }
}

Imagery

Inicio do debug do projeto Chamada do serviço Erro ao chamar o serviço

  • What is your version of IIS?

  • @jbueno I’m debugging it by Visual Studio 2013. Let’s see here.

  • @jbueno 7.5 IIS Express

  • Do you use Webservice ASMX? I have a question on the Stack: http://answall.com/questions/34145/como_consumer-um-webservice-asmx-atrav%C3%A9s-do-ajax-do-jquery/34148#34148

  • @Marconi I’m using asmx. But it’s still the same problem. I’m trying to figure out how to debug.

2 answers

1

From the looks of it, this is a fairly common problem when using IIS 7.5.

According to this answer in Stackoverflow, you should add this to 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>

0

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

routes.IgnoreRoute("{resource}.asmx/{*pathInfo}");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.