Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Daryl Butler   on May 26 In Asp.net Category.

  
Question Answered By: Steve Boyd   on May 26

Well, I've been looking at httphandlers as you know.
FrameworkSDK\Samples\QuickStart\aspplus\samples\apps\handler\cs

What you can do is this ::
put this in your web.config
<httpHandlers>
<add verb="*" path="myfile.cs" type="Acme.SimpleHandler, SimpleHandler" />
</httpHandlers>

if you set IIS to server  file extensions ".kkk" you can get the handler to specifically handle the file  of type myfile.kkk .... the extension is pretty much immaterial so you might as well use one that is already server by IIS ( namely and perhaps .resources or .cs ... the point being that a single url  maps to the handler)
So really your file doesn't even have to exist ... as long as the handler code (i.e. dll ) is in the bin

So then when you call the url ... say http://localhost/QuickStart/aspplus/samples/apps/handler/cs/myfile.cs then you can get the handler to handle it.

That handler wouldn't necessarily have to be in a sepearte dll, it could be part of your web app ... so long as you put the right type in the webconfig add verb.

So I think that may be it.

I haven't coded or tried it yet outside of messing about .... but if you specify an url for say a web controls  ImageUrl property, and you have a handler to spit out an image, both being wrapped in the same dll and in the bin, along with the altered web.config then the control  should get the generated image at runtime.

Problems that may arise are that if you wrap the handler into the same control as the server control, the the user may not (and probably wont) add that server control to the toolbox from that webapps bin (where it needs to be), and you also have to inform him to alter his web.config.

But I think the method would work  for pulling images from dll's and serving them to aspx pages via the handled url.

The great thing is that you don't even need a physical file at the url, it's handles from the dll ... so it is (sort of ) internal. But it's not fully internal  because you need to venture out just that little bit to get on the right side of a response stream. The hassles arise because you HAVE to givethe web control an ImageUrl ... and you cannot give it an image .... so you need to get on the other side of the server to collect the image.

There may be a way to handle it completely internally .... i.e. without the web.config bit ..... I (think I did) read something about adding handlers verbs programmatically.

If that can be done then there's a chance ... else th eabove outline may (as far as my knowldeg takesme) be the best solution to get it at least up and running.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Accessing resources from Server Control Or get search suggestion and latest updates.


Tagged: