Last post Mar 24, 2010 01:24 PM by g_rahman
Mar 22, 2010 08:10 AM|ErMasca|LINK
I am implementing a HttpModule that picks diferent segments from a URL and decides which kind of Page to serve.
Public Page, Private Page, Service Page and so on....
This pages dont have a static file to rely on, so RewritePath was out of the question....., lets say it does for the post's sake
The problem comes when introducing extensionless URLS and [WebMethods].
i checked and PathInfo will return null for extensionless files.
PathInfo is used to acquire the WebMethod in the BasePage, right?
PathInfo has no setter.
Obviously my workaround is to send my Jquery ajax call to a Default.aspx which inherits from my BasePage, but thats ugly.
Very ugly and defeats from Design the purpose of my framework.
What am i doing wrong?
Thanks in advance
HTTPModule and HttpHandler
Mar 24, 2010 09:59 AM|g_rahman|LINK
I don't understand the ins and outs of WebMethods so this may not be helpful...
There are several other members of the Request object that give you path information, including Request.RawUrl. You might be able to parse the information you need from there.
Or maybe you mean that you'd like it to be more automated than that since you can't know ahead of time where the page ends and the WebMethod begins. If I had to guess, I'd say that ASP.NET can't know either. It probably recognizes PathInfo only when it comes
after a file with an extension. If there's no extension, it looks like a directory to the URL parser.
Mar 24, 2010 10:39 AM|ErMasca|LINK
i know how to extract segments from URLs. Thats not the topic.
PathInfo is null for extensionless urls:
i understand that the ISAPI can get if its a page or a directory, but i cant.
but PathInfo has no setter, but before you could do something like this:
context.RewritePath("~/page.aspx", pathInfo, context.Request.Url.Query);
but thats all news, isnt it?.
my new implementation doest rely on a physical page anymore, hence
context.RemapHandler(new BasePage()); My BasePages, inherit from Page. So it should enable enough funct. to allow this.The solution seems to rely on how PathInfo Calls the WebMethods, since PathInfo has no setter.Or a way for my BasePages to be able to fire
WebMethods by themselves.Other solutions would be a webservicem or my actual workaround, having a .aspx page that inherits from BasePage.but is anything but stylish.
That is what i need to figure out. A way to implement my pages from Base Classes but not .aspx files.
Mar 24, 2010 01:24 PM|g_rahman|LINK
Ah ha. I think I understand a little better now. Can you determine the name of the webmethod in your module by parsing the request URL and pass it into the page's constructor?
Then maybe in the Load event, you could check to see what webmethod, if any, should be invoked, and then use reflection to call it?
That's maybe a long shot, and probably not as stylish as you'd like. It's the first thing that pops into my head though.