Embedding an aspx page as a WebResourcehttp://forums.asp.net/t/1157368.aspx/1?Embedding+an+aspx+page+as+a+WebResourceWed, 19 Sep 2007 16:31:14 -040011573681903934http://forums.asp.net/p/1157368/1903934.aspx/1?Embedding+an+aspx+page+as+a+WebResourceEmbedding an aspx page as a WebResource <p>In my custom server controls library, I would like to include an aspx page I created that dynamically generates images (e.g. &lt;img src=&quot;GenerateImage.aspx?type=gradient&amp;width=1px&amp;height=24px&amp;direction=Vertical&amp;fromColor=#ffffff&amp;toColor=#cacaca&quot;/&gt;). This way, I won't have to copy the page to every project I want to use it in.</p> <p>&nbsp;I was hoping I could embed it as a resource. The property page allows me to set the build action to &quot;Embedded Resource&quot; and it compiles it into the .dll just fine. However, when adding the WebResource assembly attribute to the AssemblyInfo.cs file, I don't know what content-type to use. I also thought I would need to set PerformSubstitution to true.</p> <p>However, after some reading, it appears that this won't work as .net will not actually parse/compile/execute the resource as a .net page. Is this true?</p> <p>Another option is to create an HttpHandler, but that would mean adding a new extension to IIS (e.g. &quot;.image&quot;)&nbsp;and a web.config entry. This is&nbsp;worse than just copying the .aspx page to each project that wants to use it.</p> <p>&nbsp;I could have a specific website for the page that all image sources would point to, but I would really like a more &quot;elegant&quot; solution like embedding the page into the .dll and referenced via webresource.axd.</p> <p>Is there a way to embed an aspx page as a resource or some other &quot;elegant&quot; way to implement the dynamic generation of images that could be packaged in a library?</p> 2007-09-12T01:31:25-04:001908669http://forums.asp.net/p/1157368/1908669.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p>Hi,</p> <p>From your description, do you mean you want to create your image dynamically by the aspx page which contains some logic, right?<br> When the aspx page is called, parameters should participate in the logic and determine which image should be listed,right? But since the src property of a image needs a image typed file, so you still need to set the content type of your aspx page to a image type, and use stream reader to read the image file, otherwise, IIS would regard it as an ordinary .Net page.</p> <p>Instead of the method above, why dont you create a method which works for handling the dynamic image creating.&nbsp; Just add all of your Web Resources (images) into your project, and in that method, set some input parameters such like imageid, height, width and etc determine the imageurl based on the imageid, create an instance of Image object with those parameters, and return it to the main application.</p> <p>Some codes which might help you.</p> <pre class="prettyprint">public Image getImage(string imageid, string width, string height,string align) { string imageurl=&quot;&quot;; //.. write your logic here, get the imageurl based on the imageid Image ig = new Image(); ig.ImageUrl = imageurl; ig.Width = width; ig.Height = height; ig.ImageAlign = align; return ig; }</pre><pre class="prettyprint"><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-font-kerning: 0pt; mso-no-proof: yes">And then, on your page, you can add the control which returned from getImage method onto your page or any PlaceHoder controls.</SPAN></P><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-font-kerning: 0pt; mso-no-proof: yes"><?xml:namespace prefix = o /><o:p>&nbsp;</o:p></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-font-kerning: 0pt; mso-no-proof: yes"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p><pre class="prettyprint">Image object_ig = getImage(args1,args2,args3,args4); Page.Form.Controls.Add(object_ig); <SPAN class=cmt>// or this.PlaceHolder1.Controls.Add(object_ig);</SPAN> </pre>&nbsp;&nbsp;</o:p></SPAN> </PRE>&nbsp;Thanks. 2007-09-14T07:20:30-04:001909281http://forums.asp.net/p/1157368/1909281.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p>I'm sorry, I already have the page. It's working just fine.</p> <p>What I want is a way to&nbsp;include that page in my custom control library so that it's always available to my custom controls. I was hoping I could embed it as a resource that can be requested via WebResource.axd.</p> <p>&nbsp;</p> 2007-09-14T14:03:00-04:001910875http://forums.asp.net/p/1157368/1910875.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p>Hi,</p> <p>But what exactly is the problem with what you're trying to do? Although I personally would see no good purpose for doing so, but, can't you just embed it as an ordinary resource with [assembly: WebResource(&quot;Name&quot;, &quot;Content Type&quot;, true)] &lt;the last boolean argument meant for resolving an embedded resource which potentially points to another embedded resource with &lt;%= WebResource(&quot;Name&quot;)%&gt;, such as an ASPX page&gt; and request a reference to it with Page.ClientScript.GetWebResourceUrl(this.GetType(), &quot;Name&quot;)?<br> </p> 2007-09-16T04:41:36-04:001910899http://forums.asp.net/p/1157368/1910899.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Max Kukartsev</h4> <p>Although I personally would see no good purpose for doing so ...</p> </blockquote> &nbsp; <p>I want this page as part of my custom control library so&nbsp;that it can be used by my custom controls. I'm not doing this for any single application. I don't want to copy an .aspx file around to any project that wants to use my custom controls. I don't want to&nbsp;require modification of IIS configuration. I want it&nbsp;in the&nbsp;code library. I'm not talking about the App_Code folder of a web application. I'm talking about a class library. A seperate project all by itself. A .dll file that can be installed in the GAC of our web servers and would be available to any web site that wants to use it without any hassles.</p> <p>What would you suggest?</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Max Kukartsev</h4> <p>[assembly: WebResource(&quot;Name&quot;, &quot;Content Type&quot;, true)]</p> </blockquote> <p>What's the content type for an .aspx page? I can't find one.</p> <p>Setting true for the PerformSubstitution attribute is only for parsing other web resource urls in the embedded content - not executing code. From what little I've been able to find, it appears that you can only embed static files as resources.</p> <p>&nbsp;</p> <blockquote><span class="icon-blockquote"></span> <h4>Max Kukartsev</h4> <p>can't you just embed it as an ordinary resource</p> </blockquote> <p>No. That's why I posted. I can't figure out how to get this to work.</p> <p>How do charting&nbsp;controls do it? You drop in a .dll and use it - it creates charts dynamically. Ancient Chinese Secret? [:@]</p> <p>/js</p> 2007-09-16T06:35:15-04:001910966http://forums.asp.net/p/1157368/1910966.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource Why don't you create a simple class file that does the stuff? Instead of querying by url, calling its methods with the needed params will be better. 2007-09-16T09:50:59-04:001911075http://forums.asp.net/p/1157368/1911075.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p>Because image/background sources are pulled by the browser as seperate http requests. You can't &quot;embed&quot; images in the response stream that is sending the html for the page. The code for the custom controls is not &quot;querying by url&quot; - it's setting the src/imageurl properties, which can only be urls.</p> <p>&nbsp;</p> 2007-09-16T14:26:45-04:001911086http://forums.asp.net/p/1157368/1911086.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource Oh, yes, sorry for not thinking :-) <br> In a project I worked, we have a similar stuff. We solved it with a handler. That handler inherited from MyHandler, that implemented IHandler. MyHandler was in a separate control library, and there we proceed the request. <br> It decouples a lot, but anyway it requires an ashx on each website.<br> I think that you can't do what you want without having an ashx or aspx in the website. <br> <br> Hope this helps. 2007-09-16T14:45:25-04:001911135http://forums.asp.net/p/1157368/1911135.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p>Well, you could implement a handler as a class - it doesn't have to be an .ashx file. Using .ashx files is nice because IIS and ASP.NET is already configured for that extension, but the file would have to be in the web project - not in a class library - like you said.</p> <p>If I do implement it as a class, then I would have to use a different extension, register the extension in IIS, and add a httphandler to web.config for each project. That's more than just adding a reference to my libary in the web project&nbsp;and it just working.</p> <p>&nbsp;</p> <p>Wait.. What if.... hmm.... (gears spinning)</p> <p>&nbsp;</p> <p>What if I kinda hijack the .ashx extension. The global web.config (in the framework's config folder) has this httpHandler entry:</p> <pre class="prettyprint">&lt;add path=&quot;*.ashx&quot; verb=&quot;*&quot; type=&quot;System.Web.UI.SimpleHandlerFactory&quot; validate=&quot;True&quot;&gt;</pre> <P mce_keep="true">What if, in the web project's web.config, I add this httpHandler entry:</P><pre class="prettyprint">&lt;add path="GenerateImage.ashx" verb="GET" type="MyControls.Handlers.MyImageHandler, MyControls" validate="True"&gt;</pre> <p>I could have something in my code library check for the existence of that entry in the web.config and add it if it's not there. I wonder if this would&nbsp;get checked&nbsp;before the *.ashx in the global web.config. I wouldn't have to register a new extension is IIS.</p> <p>I see a possible problem of IIS checking if the &quot;file&quot; exists and throwing an IIS error since there actually isn't a GenerateImage.ashx file. I could have the code that checks the web.config also create&nbsp;a placeholder file.</p> <p>This is pretty ugly, but it would meet my requirements if it works.</p> <p>/js</p> 2007-09-16T16:25:25-04:001911214http://forums.asp.net/p/1157368/1911214.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p></p> <blockquote><span class="icon-blockquote"></span> <h4>jshepler</h4> What's the content type for an .aspx page? I can't find one.</blockquote> <p></p> <p>Same as an html file, &quot;text/html&quot;, because the output from an ASPX page when rendered would essentially be HTML.</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>jshepler</h4> How do charting&nbsp;controls do it? You drop in a .dll and use it - it creates charts dynamically.</blockquote> <p></p> <p>Oh, I see what you mean, I think... You're asking how can charting controls dynamically have the url to their generated image?</p> <p>Well, I'd try to intercept the request myself by handling the OnLoad() event in the control class, and checking to see if the url has a special query parameter, in which case - clear the response, render the image, and that's it.<br> In your render method, make the url of the image tag to be the same page with the special query string parameter. This is just how anyone would solve the problem of always having to have image files on the hard drive for them to be embedded in the HTML.</p> <p>[Idea]&nbsp;Even better, - because the approach above could very easily not work because it's based on the custom control model and you're not programming an ASPX page directly, I'd suggest using <a href="http://www.aisto.com/roeder/dotnet/">.NET Reflector</a> on the charting control library you speak of and analyze the code yourself to look for the functionality you seek.<br> </p> <p>It's not exactly ideal, but worth a shot. Besides, if the control has some perfected special way to do it, you wouldn't have to reinvent the wheel... [:D]<br> </p> 2007-09-16T19:25:58-04:001911288http://forums.asp.net/p/1157368/1911288.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Max Kukartsev</h4> You're asking how can charting controls dynamically have the url to their generated image?</blockquote> &nbsp; <p>Not exactly.&nbsp;Your description implies the control generates the image, saves it do disk, then spits out a url to it. That's not what I'm after. </p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Max Kukartsev</h4> Well, I'd try to intercept the request myself by handling the OnLoad() event in the control class, and checking to see if the url has a special query parameter, in which case - clear the response, render the image, and that's it.</blockquote> <p>That's an interesting idea. Although I would do it much sooner than OnLoad (probably in OnInit)&nbsp;so as not to waste as much time on all the page/control processing that happens before it. Could also foul stuff up for the page developer who may be doing something in the page/masterpage's Page_Init(). For example, if the page developer is keeping track of page hits and is doing it in the Page_Init of the site's master page - hijacking the request in this way would give inaccurate results. </p> <p>It is something else to consider. Thanks. </p> <p>/js</p> 2007-09-16T21:51:39-04:001911294http://forums.asp.net/p/1157368/1911294.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p></p> <blockquote><span class="icon-blockquote"></span> <h4>jshepler</h4> Not exactly.&nbsp;Your description implies the control generates the image, saves it do disk, then spits out a url to it. That's not what I'm after.</blockquote> <p></p> <p>Actually, that's exactly the situation which my description and the text that follows <b>describes how to avoid.</b></p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>jshepler</h4> Although I would do it much sooner than OnLoad (probably in OnInit)&nbsp;so as not to waste as much time on all the page/control processing that happens before it.</blockquote> <p></p> <p>I don't think you should, though. If the user programmatically alters your control's properties which should affect the output image, chances are he'll do it in Page_Load(), and the problem is that way you can't reflect the change(s). At least not after a postback, if you store your control's data in viewstate.<br> </p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>jshepler</h4> Could also foul stuff up for the page developer who may be doing something in the page/masterpage's Page_Init().</blockquote> <p></p> <p>I don't think so. You see, a request for the dynamic image file, (denoted with a special additional query string parameter) is another request which is processed later, separate from the original request for the actual ASPX page, which you shouldn't tamper with. The second request will come when the browser requests the image file, and the only way you can distinguish between the original request and this one is by adding a query string parameter, and intercepting the request then. Also, don't forget to set the content output to image/jpeg or a different format in the case of interception, or &quot;hijacking,&quot; as you call it.<br> </p> 2007-09-16T22:02:06-04:001911408http://forums.asp.net/p/1157368/1911408.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p>What do you think is going to happen on that <em>second</em> request <em>before</em> the control &quot;intercepts the request&quot;?</p> <p>Let's assume for the moment that I implement a control like you suggest where the controls&nbsp;OnLoad() checks the querystring</p> <pre class="prettyprint">protected override void OnLoad(EventArgs e) { HttpContext context = HttpContext.Current; if(context.Request.QueryString[&quot;generateImage&quot;] != null) { Bitmap image = GenerateImage(); context.Response.Clear(); context.Response.ContentType = &quot;image/jpeg&quot;; image.Save(context.Response.OutputStream, ImageFormat.Jpeg); context.Response.End(); } }</pre>Let's say I have a page with one of these controls on it. Let's say the page has a Page_Init() <pre class="prettyprint"><SPAN class=kwd>protected void</SPAN> Page_Init(<SPAN class=kwd>object</SPAN> sender, EventArgs e) { <SPAN class=cmt>// we don't want to count postbacks, only original hits</SPAN> <SPAN class=kwd>if</SPAN>(IsPostBack == false) { <SPAN class=cmt>// code here to increment a counter in a database</SPAN> } }</pre> <p>When I first request that page, 2 hits are going to be registered in the database. For every postback, an additional hit will be registered in the database. This is because that second request for the image is actually a request to the page (and IsPostBack will be false)&nbsp;and normal page processing will happen&nbsp;until the control hijacks the request.</p> <p>&nbsp;</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Max Kukartsev</h4> If the user programmatically alters your control's properties which should affect the output image, chances are he'll do it in Page_Load(), and the problem is that way you can't reflect the change(s). At least not after a postback, if you store your control's data in viewstate.</blockquote> <p>That shouldn't affect when the control checks the querystring on the second request. </p> <p>The first request is what will build the url with any querystring properties that describe the image to generate. Any changes a developer would do in Page_Load (or after in an event handler) only affects the generation of the url (which would happen in the control's OnRender like you said). </p> <p>When the second request comes in, all the changes are already reflected in the querystring. This should be hijacked as soon as possible - like in the control's constructor. </p> <p>/js</p> 2007-09-17T01:20:18-04:001911450http://forums.asp.net/p/1157368/1911450.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p></p> <blockquote><span class="icon-blockquote"></span> <h4>jshepler</h4> What do you think is going to happen on that <em>second</em> request <em>before</em> the control &quot;intercepts the request&quot;?</blockquote> <p></p> <p>Exactly. This is what I've said in my first reply, meaning that perhaps additional rendering logic could've already taken place, and maybe still will, and bang- you've ended the request by then. So I say, the way to go is to test it, and perhaps disassemble an existing control library projects which you mentioned and see how it does it. A good and simple thing to do would be to place that charting control onto an ASPX page and run the project, and then check the url of the generated image; it may answer some questions.</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>jshepler</h4> <span class="kwd">protected void</span> Page_Init(<span class="kwd">object</span> sender, EventArgs e) { <span class="cmt">// we don't want to count postbacks, only original hits</span> <span class="kwd"> if</span>(IsPostBack == false) { <span class="cmt">// code here to increment a counter in a database</span> } }</blockquote> <br> <p></p> <p>Are you sure the page already knows if the request is a postback or not in its Init() processing stage? I mean, I've never seen anyone check IsPostBack in Init(), only in Page_Load()</p> <blockquote><span class="icon-blockquote"></span> <h4>jshepler</h4> <p></p> <p>Any changes a developer would do in Page_Load (or after in an event handler) only affects the generation of the url (which would happen in the control's OnRender like you said). </p> <p>When the second request comes in, all the changes are already reflected in the querystring.</p> <p></p> </blockquote> <p></p> <p>That makes sense, I see now, but wait? You plan to transfer <i>actual data </i> through the query string, not just use it as a bit flag/marker?<br> </p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>jshepler</h4> This should be hijacked as soon as possible - like in the control's constructor.</blockquote> <p></p> <p>Whoa whoa whoa. At the time when the control's constructor is called - no query string or form or any of the request details have yet been loaded. The earliest they can be accessed is Page_Load, or OnLoad() in a custom control class.</p> <p><i>Also, you forgot to call the base implementation of OnLoad(). This will cause other events not to fire for the control.</i><br> </p> 2007-09-17T02:06:37-04:001911455http://forums.asp.net/p/1157368/1911455.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p>I forgot to mention, - if you have an option to use a handler instead of a custom control - go for it. [Yes]<br> ASP.NET HTTP handlers give you complete control over what is output, whereas with a custom control it could get confusing quickly, because a control is part of a larger ASP.NET page processing cycle.<br> </p> <p>However, there are more than enough examples where this isn't the best option, (to say the least). A charting control is a control library, - due to deployment issues with having it as a handler.<br> </p> 2007-09-17T02:12:48-04:001911511http://forums.asp.net/p/1157368/1911511.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Max Kukartsev</h4> Are you sure the page already knows if the request is a postback or not in its Init() processing stage? I mean, I've never seen anyone check IsPostBack in Init(), only in Page_Load</blockquote> <p>Yes, I'm sure. I've used it many times in Page_Init. </p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Max Kukartsev</h4> You plan to transfer <i>actual data </i>through the query string, not just use it as a bit flag/marker?</blockquote> <p>Image requests are GETs, not POSTs - so no form information (e.g.&nbsp;the hidden form field __VIEWSTATE) can be used.&nbsp;There isn't much <em>actual data</em> to pass. The image type (solid, gradient), dimensions, and color(s). </p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Max Kukartsev</h4> Whoa whoa whoa. At the time when the control's constructor is called - no query string or form or any of the request details have yet been loaded. The earliest they can be accessed is Page_Load, or OnLoad() in a custom control class.</blockquote> <p>Not true. The Request object already exists before the page is even instantiated. The Request property of the page is just a shortcut to HttpContext.Current.Request. The control can get at the querystring via HttpContext.Current.Request.QueryString. </p> <p>In fact, I could put this functionality in the constructor of a custom page class that the .aspx pages extends (instead of System.Web.UI.Page) and have the page itself respond to dynamic image requests. That would be even better. However, that would require page developers to use my custom page control in order for my custom controls to get dynamic backgrounds&nbsp;and I don't want to do that. </p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Max Kukartsev</h4> &nbsp;if you have an option to use a handler instead of a custom control - go for it.</blockquote> <p>I am considering the handler route by hijacking the built-in .ashx mapping like I describe in <a href="http://forums.asp.net/t/1157368.aspx#1911135">http://forums.asp.net/t/1157368.aspx#1911135</a>. If that works, it would only require an entry in the web.config, which I could do from code to make sure it's there. It would be nice if I could have visual studio automatically add the web.config entry when a reference is made to my library. The handler approach is more appealing than what we've been discussing, but it requires modifying the web.config. </p> <p>/js </p> <p>&nbsp;</p> 2007-09-17T03:25:25-04:001913127http://forums.asp.net/p/1157368/1913127.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p></p> <blockquote><span class="icon-blockquote"></span> <h4>jshepler</h4> Not true. The Request object already exists before the page is even instantiated. The Request property of the page is just a shortcut to HttpContext.Current.Request. The control can get at the querystring via HttpContext.Current.Request.QueryString.</blockquote> <p></p> <p>Wow, you're right! The request data is indeed loaded by Page_Init! But it contradicts this excellent book on ASP.NET, Pro ASP.NET in C# 2005, there was a problem addressed relating to themes (ch.15) where all themes must be applied by Init processing stage, (and any attempt to do so afterwards results in an exception) and post data from controls was only loaded by Page_Load, so Server.Transfer() method was used instead to fix that, - to cause another request to the same page to apply the theme.<br> Oh no wait! I see what it is! The form and query string data is loaded by the time Page_Init fires, but the <i>control data</i> (such as the Text property in a TextBox control) is not yet assigned. I see the way now, sorry. [:&#36;]<br> </p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>jshepler</h4> The handler approach is more appealing than what we've been discussing, but it requires modifying the web.config.</blockquote> <p></p> <p>No, not necessarily, unless you want to route certain requests to the handler by using constructs such as wildcards, or if you want to support custom file types registered with ASP.NET by IIS. If you just want to have a handler which handles requests for its filename, with extension ashx, which is already registered with ASP.NET, no modification of Web.config is necessary.<br> </p> 2007-09-17T20:42:57-04:001913221http://forums.asp.net/p/1157368/1913221.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Max Kukartsev</h4> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>jshepler</h4> The handler approach is more appealing than what we've been discussing, but it requires modifying the web.config.</blockquote> <p>No, not necessarily, unless you want to route certain requests to the handler by using constructs such as wildcards, or if you want to support custom file types registered with ASP.NET by IIS. If you just want to have a handler which handles requests for its filename, with extension ashx, which is already registered with ASP.NET, no modification of Web.config is necessary.<br> </p> <p></p> </blockquote> <p></p> <p>I'm talking about <em>changing</em> the handler for a specific .ashx request - which does indeed <em>require</em>&nbsp;modifying the web.config file. You took what I said out of context.</p> <p>/js</p> 2007-09-17T22:00:35-04:001916792http://forums.asp.net/p/1157368/1916792.aspx/1?Re+Embedding+an+aspx+page+as+a+WebResourceRe: Embedding an aspx page as a WebResource <p>Just to note that I went the handler route.</p> <p>I created a class file in my custom control code library - GenerateImageHandler.cs</p> <p>The class &quot;GenerateImageHandler&quot; implements IHttpHandler.</p> <p>I added the following to the web.config:</p> <pre class="prettyprint">&lt;httpHandlers&gt; &lt;add verb=&quot;GET&quot; path=&quot;GenerateImageHandler.ashx&quot; type=&quot;ECR.WebControls.HttpHandlers.GenerateImageHandler, ECR.WebControls&quot;/&gt; &lt;/httpHandlers&gt;</pre> <p>Since the .ashx is already mapped in IIS, I do not need to require page developers that want to use my custom controls to touch IIS.</p> <p>It tested successfully.</p> <p>/js</p> 2007-09-19T16:31:14-04:00