Hello guys, Have a file "__captcha.aspx", which generates a captcha jpeg by Code: <img src="__captcha.captcha" /> I'm using that simple code to URL Rewrite in Application_BeginRequest in Global.asax: Code: string parts = HttpContext.Current.Request.Path.ToLower(); if (parts.Contains(".captcha")) { Context.RewritePath(parts.Replace(".captcha", ".aspx")); } So, the problem is: on my local server works great, on Winhost - ERROR404. I'm upset how to solve?
Hello Ray, Let me show you this way: Code: HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Module IIS Web Core Notification MapRequestHandler Handler StaticFile Error Code 0x80070002 Requested URL http://somewebsite.org:80/__captcha.captcha Physical Path E:\web\somewebsite\__captcha.captcha Logon Method Anonymous Logon User Anonymous May be it needs to restart an Application to refresh and enable Global.asax Application_BeginRequest?
The 404 error is fairly straight forward and it does mean it cannot find an object or a file. Make sure the source file is coded to the correct path. I've also seen this when an assembly may not be installed on the server. Because of security we cannot install any 3rd party components directly on the server so make sure that what ever assembly your application is using is bin deployable. Try uploading the assemblies in your Bin folder. The fact that it works on your computer does let us believe that you have something in your servers GAC that we do not have installed. Like I said hopefully it is bin deployable. Also just as a test also set the MIME type for .captcha. You can do this in IIS 7 Manager under the MIME type module. http://support.Winhost.com/KB/a628/using-the-microsoft-iis-70-manager.aspx
If I use .aspx extension, everything's going great! And, as far as I understand, I'm not using no any components to rewrite the url, I just use C# code inside of Global.asax (even do not edit web.config/machine.config file) P.S.: It's a panic))), I don't understand, why that is going on: it is so easy to replace some text in a string, but doesn't work on Winhost server((( Most of all I think "Application_BeginRequest" did not enabled/started/refreshed/etc., so Server don't even know that I inserted the rewriting code inside of it.
That is different solution ("for a black day" haha))), it's good if I have a real "captcha.captcha" file, but now I have a normal "captcha.aspx", just need to rewrite all incoming requests contains ".captcha" to the real ".aspx" file. P.S.: Ray, I'm so sorry, disturbing you whole day ^^
Ray, I'll try to make it clear (sorry if repeated again): Have I have a real __captcha.aspx file, which generates a "image/jpeg" stream Need Need to make a virtual URL rewriting like <img src="__captcha.captcha" /> which will touch the real .aspx file, not .captcha Now Now server tries to open __captcha.captcha file instead of looking thru URL rewriting code. MIME type - created, Application_BeginRequest - created Just checked again on my server: Code: protected void Application_BeginRequest(object sender, EventArgs e) { string parts = HttpContext.Current.Request.Path.ToLower(); if (parts.Contains(".captcha")) { Context.RewritePath(parts.Replace(".captcha", ".aspx")); } } Working the best way (((
I really do not have enough information to troubleshoot this. It would help if I have instructions on how to actually replicate the error message. If you don't want to post your URL on this forum then email it to me and send me instructions on how to replicate the error message.
Guys! Fixed! Hurrrayyy! Application_BeginRequest was really omitted by Winhost configuration by default. BeginRequest runs only for *.aspx files (for sure "*.captcha" extension is not an active server page by server's opinion) I've been just added "*.captcha" extension into Handler Mappings related to System.Web.UI.PageHandlerFactory and it starts! Hope it'll be useful for guys, who need use own extensions on a website. P.S.: Ray, thanks for idea about MIME, I started from there
Thanks for the explanation. Actually I saw something similar to this and we went through a series of steps and the last one was actually the MIME configuration. It worked after that. Although I really was not sure why that would work. Your explanation shed more light to it and the next time I point to that direction I can explain further why it is needed.