I have created a HttpHandler and added this into the web.config, now at first this didn't work as IIS looked like it wasn't forwarding on my request to .Net so i added an application extension mapping to the site with the following: Executable: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll Extension: .js Verbs: All Script Engine: true Verify that file exists: false Once i have added this my handler is then showing the correct output, however now all .js files are not being pushed out so the javascript on the site is now not there, I have tested this in the global.asax and if i add in the following for .js files HttpContext.Response.Write(" "); it then completes the request and pushes the files out. The reason I need to do this is because I need to produce the .js on the fly via a db. What am I missing? Here are the code snippets: HTTP HANDLER using System; using System.Web; namespace C4Publisher.HttpHandler { public class ImageUploadHandler: IHttpHandler { #region Implementation of IHttpHandler public void ProcessRequest(System.Web.HttpContext context) { HttpResponse objResponse = context.Response ; objResponse.Write("<html><body><h1>Hello 15Seconds Reader ") ; objResponse.Write("</body></html>") ; } public bool IsReusable { get { return true; } } #endregion } } <httpHandlers> <add verb="*" path="/admin/userupload_image_list.js" type="C4Publisher.HttpHandler.ImageUploadHandler" /> </httpHandlers>
Why not use a different extension and just set the content type in your response? That is probably easiest. You could also map .js files to the static file handler and map a more specific extension like *dynamic.js to your custom HttpHandler. It seems like it would be easier to do the former though. Check out how webresource.axd does this in ASP.NET 2.0. Joe K. -- Joe Kaplan-MS MVP Directory Services Programming Co-author of "The .NET Developer's Guide to Directory Services Programming" http://www.directoryprogramming.net -- "Powellze" wrote in message news:313FEAAC-EFD2-484D-8C28-9FC3F79639D2@microsoft.com... >I have created a HttpHandler and added this into the web.config, now at >first > this didn't work as IIS looked like it wasn't forwarding on my request to > .Net so i added an application extension mapping to the site with the > following: > > Executable: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll > Extension: .js > Verbs: All > Script Engine: true > Verify that file exists: false > > Once i have added this my handler is then showing the correct output, > however now all .js files are not being pushed out so the javascript on > the > site is now not there, I have tested this in the global.asax and if i add > in > the following for .js files HttpContext.Response.Write(" "); it then > completes the request and pushes the files out. > > The reason I need to do this is because I need to produce the .js on the > fly > via a db. > > What am I missing? > > Here are the code snippets: > > HTTP HANDLER > > using System; > using System.Web; > > namespace C4Publisher.HttpHandler > { > public class ImageUploadHandler: IHttpHandler > { > > #region Implementation of IHttpHandler > public void ProcessRequest(System.Web.HttpContext context) { > HttpResponse objResponse = context.Response ; > objResponse.Write("<html><body><h1>Hello 15Seconds Reader ") ; > objResponse.Write("</body></html>") ; > } > > public bool IsReusable { > get { > return true; > } > } > #endregion > } > } > > <httpHandlers> > <add verb="*" path="/admin/userupload_image_list.js" > type="C4Publisher.HttpHandler.ImageUploadHandler" /> > </httpHandlers>
Thanks Joe, I have used a HttpHandler and caught it in there, I found out one of the major issues like you say is down to the AXD, as it appears the JS gets forwarded on to this and doesn't complete the request. I have had to manually complete the request for other JS files, otherwise the other JS files were sent as empty. Got to admit I like the use of HttpHandlers :) "Joe Kaplan" wrote: > Why not use a different extension and just set the content type in your > response? That is probably easiest. You could also map .js files to the > static file handler and map a more specific extension like *dynamic.js to > your custom HttpHandler. It seems like it would be easier to do the former > though. Check out how webresource.axd does this in ASP.NET 2.0. > > Joe K. > > -- > Joe Kaplan-MS MVP Directory Services Programming > Co-author of "The .NET Developer's Guide to Directory Services Programming" > http://www.directoryprogramming.net > -- > "Powellze" wrote in message > news:313FEAAC-EFD2-484D-8C28-9FC3F79639D2@microsoft.com... > >I have created a HttpHandler and added this into the web.config, now at > >first > > this didn't work as IIS looked like it wasn't forwarding on my request to > > .Net so i added an application extension mapping to the site with the > > following: > > > > Executable: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll > > Extension: .js > > Verbs: All > > Script Engine: true > > Verify that file exists: false > > > > Once i have added this my handler is then showing the correct output, > > however now all .js files are not being pushed out so the javascript on > > the > > site is now not there, I have tested this in the global.asax and if i add > > in > > the following for .js files HttpContext.Response.Write(" "); it then > > completes the request and pushes the files out. > > > > The reason I need to do this is because I need to produce the .js on the > > fly > > via a db. > > > > What am I missing? > > > > Here are the code snippets: > > > > HTTP HANDLER > > > > using System; > > using System.Web; > > > > namespace C4Publisher.HttpHandler > > { > > public class ImageUploadHandler: IHttpHandler > > { > > > > #region Implementation of IHttpHandler > > public void ProcessRequest(System.Web.HttpContext context) { > > HttpResponse objResponse = context.Response ; > > objResponse.Write("<html><body><h1>Hello 15Seconds Reader ") ; > > objResponse.Write("</body></html>") ; > > } > > > > public bool IsReusable { > > get { > > return true; > > } > > } > > #endregion > > } > > } > > > > <httpHandlers> > > <add verb="*" path="/admin/userupload_image_list.js" > > type="C4Publisher.HttpHandler.ImageUploadHandler" /> > > </httpHandlers> > > >