Solved

How to do  ASP.NET WebForms routing for asmx Web Services?

Posted on 2012-03-23
3
766 Views
Last Modified: 2012-05-29
Hi experts! I'm trying to enable ASP.NET WebForms routing to an asmx Web Service.

The following returns a "Type 'myproject.myservice' does not inherit from 'System.Web.UI.Page'" error:

routes.MapPageRoute(
            "The_Route_Name_For_This_Service",
            "somethingfantastic/",
            "~/services/myservice.asmx?op=MyFunction"
        )

Open in new window


How can I add paths to asmx web services to my RouteCollection?

Your help is greatly appreciated!
0
Comment
Question by:Drevo
3 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37759113
you cannot route a request to an aspx page, which is a class derived from page class which is the page's HTTPHandler to a asmx page.

By default Instance of Page is created whenever a request is made for an aspx page, however i think if you can write your own HttpModule, you can override this behaviour and have your own handler get called.
0
 

Author Comment

by:Drevo
ID: 37772783
Thanks for your comment BuggyCoder! Though you can route requests to aspx pages. I think you're right that something needs to be overridden to route to an asmx web service. I don't know exactly how though, which leaves this question still open. Perhaps some kind of extension of IRouteHandler and/or IHttpHandler?

In the meantime I'm just checking for specific URL path patterns in Application_BeginRequest and doing a Context.RewritePath to the matched web service.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now