Deb
Deb

Reputation: 991

Accessing Webservice from Asp.net MVC

I have a MVC2 App which also includes a Non MVC part (regular Asp.Net 3.5 pages).

I am calling webservice (Not WCF) from Non MVC pages to populate autocompletes.

Both MVC parts and Non-MVC parts work fine in my developers machine.

When i host my application in IIS, i cant access the webmethods in my webservice. I checked with firebug it returns

The controller for path '/payroll/WS/MVCArch.asmx/JqUiGetEmp' was not found or does not implement IController. '

Here my virtual directory name is Payroll. and my Non MVC pages are located under a folder called "RepDocs" which is under the root of the application. My Webservice folder "WS" is also under the root of the application. The request was sent from a non mvc page under "RepDocs" folder.

How come the same code works in VSHOST and not in IIS (XP sp3) ? am i missing something ?

Please help.

EDIT

I have modified my global.asax to exclude routes as follow

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("favicon.ico");
routes.IgnoreRoute("WS/{resource}.asmx/{*pathInfo}");
//routes.IgnoreRoute("{*allasmx}", new { allasmx = @".*\.asmx(/.*)?" });
routes.MapRoute(
    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
    new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

Now i get this error

The HTTP verb POST used to access path '/Payroll/ws/MVCArch.asmx/JqUiGetOffice' is not allowed.

I added the following to the Web.config

<webServices>
    <protocols>
      <add name="HttpGet"/>
      <add name="HttpPost"/>
      </protocols>
</webServices>

Still no luck.

Upvotes: 2

Views: 1879

Answers (1)

VJAI
VJAI

Reputation: 32758

You have to ignore the route to the web service in Global.asax.cs

routes.IgnoreRoute("{*allasmx}", new {allasmx=@".*\.asmx(/.*)?"});

Upvotes: 2

Related Questions