It supposed to be that using httpModules could rewrite Urls to be handled by ASP.net engine, and then write .ashx handlers to return intended files; all of this without any physical access to the server. For my website I have written httpModules and [.ashx]
httpHandlers for .apsx. .xml, .xap, and image files. All handlers work pretty much the same way: "category" directory is imaginary; remove that from uri and return the file. For example: ~/category/default.aspx returns file at ~/default.aspx
This website works perfectly in my testing environment. However, on the deployment server (godaddy, shared) if I use Url Rewriting (my request starts with /category) only if I requested .aspx page it gets returned; all other types return 404 not found!
I looked in the web.config and saw <system.webserver> did not duplicate everything in <system.web>, so I added the handler
Why .aspx pages reroute fine, but the types handled by a .ashx each (.xap, .xml, .jpg), return 404?
<add
name="zzzzashxHandler"
verb="*"
path="*.ashx"
type="System.Web.UI.SimpleHandlerFactory"/>
to it. I published that to the deployment server, and still no luck. Can anyone tell me how to find out what is wrong?
Deployment server: shared server, godaddy, [most likely medium trust, ] ASP.net 3.5, IIS7
Here is a simplified version of my web.config. I might have errors in <system.webserver>:
Elburze
Member
1 Points
6 Posts
Url Rewriting; 404 not found on deployment server
Apr 20, 2010 09:20 AM|LINK
It supposed to be that using httpModules could rewrite Urls to be handled by ASP.net engine, and then write .ashx handlers to return intended files; all of this without any physical access to the server. For my website I have written httpModules and [.ashx] httpHandlers for .apsx. .xml, .xap, and image files. All handlers work pretty much the same way: "category" directory is imaginary; remove that from uri and return the file. For example: ~/category/default.aspx returns file at ~/default.aspx
This website works perfectly in my testing environment. However, on the deployment server (godaddy, shared) if I use Url Rewriting (my request starts with /category) only if I requested .aspx page it gets returned; all other types return 404 not found!
http://www.shopstaple.net/category/dzDebug.aspx
returns default.aspx (good)http://www.shopstaple.net/category/ClientBin/GeneratedImages/dzDebug/Metadata.xml
returns 404http://www.shopstaple.net/category/ClientBin/GeneratedImages/dzDebug/dzc_output_images/sunset_files/9/0_0.jpg
returns 404I looked in the web.config and saw <system.webserver> did not duplicate everything in <system.web>, so I added the handler
Why .aspx pages reroute fine, but the types handled by a .ashx each (.xap, .xml, .jpg), return 404?
<add name="zzzzashxHandler" verb="*" path="*.ashx" type="System.Web.UI.SimpleHandlerFactory"/> to it. I published that to the deployment server, and still no luck. Can anyone tell me how to find out what is wrong?Deployment server: shared server, godaddy, [most likely medium trust, ] ASP.net 3.5, IIS7
Here is a simplified version of my web.config. I might have errors in <system.webserver>:
Here is also my xmlHandler.ashx:
<%@ WebHandler Language="C#" Class="XMLHandler.XMLHandler" %> using System; using System.Web; namespace XMLHandler { public class XMLHandler : IHttpHandler { public bool IsReusable { get { return false; } } public void ProcessRequest(HttpContext context) { context.Response.Clear(); context.Response.ContentType = "text/xml"; context.Response.ContentEncoding = System.Text.Encoding.UTF8; string[] UriSections = context.Request.RawUrl.Split(new Char[] { '/' }); if (!(UriSections[2] == "category" && UriSections[3] == "ClientBin" && UriSections[4] == "GeneratedImages")) throw new Exception("Requested xml file outside of category/ClientBin/GeneratedImages directory."); System.Text.StringBuilder xmlFile = new System.Text.StringBuilder(""); for(int i=0; i<UriSections.Length; i++) { if (UriSections[i] != "category") { if (i == UriSections.Length - 1) xmlFile.Append(UriSections[i]); else xmlFile.Append(UriSections[i] + "/"); } } context.Response.TransmitFile(xmlFile.ToString()); } } }