ASP.NET Url problem
-
Hi! I am trying to implement custom error redirection for my asp.net pages. Take this example URL: http://server/dir/nested/page.aspx Using custom error redirection settings in web.config (by turning custom error mode to "on"), and writing code in the application_error method in global.asax, I can take care of the following mistyped(maybe intentionally) URL, and take the user to a custom page instead of showing a stack trace. http://server/dir/nested/~page.aspx (Note the '~') The problem is when I try type http://server/dir/~nested/page.aspx. In this case none of my error handlers are triggered. One way of solving this issue is to use IIS filters. My question is whether we can handle this in any other manner (using ASP.NET)? Thanks!
-
Hi! I am trying to implement custom error redirection for my asp.net pages. Take this example URL: http://server/dir/nested/page.aspx Using custom error redirection settings in web.config (by turning custom error mode to "on"), and writing code in the application_error method in global.asax, I can take care of the following mistyped(maybe intentionally) URL, and take the user to a custom page instead of showing a stack trace. http://server/dir/nested/~page.aspx (Note the '~') The problem is when I try type http://server/dir/~nested/page.aspx. In this case none of my error handlers are triggered. One way of solving this issue is to use IIS filters. My question is whether we can handle this in any other manner (using ASP.NET)? Thanks!
The way we have implemented an incorrect link before was by implementing a custom 404 error site /Errors/404.aspx, and setting IIS to redirect to the 404 page. This allows us to have a link to an item say www.someurl.com/Guid... the 404 is fired and in the 404 we see if a Guid was supplied, if so we look it up and redirect the user to that item. I think it's easier to catch 404 errors using the IIS settings than it is to try to catch the 404 in the Global.asax. I think this is what you are asking. Steve West Lead Architect - ProjectInsight.net Web-Based Project Management Software http://www.projectinsight.net
-
The way we have implemented an incorrect link before was by implementing a custom 404 error site /Errors/404.aspx, and setting IIS to redirect to the 404 page. This allows us to have a link to an item say www.someurl.com/Guid... the 404 is fired and in the 404 we see if a Guid was supplied, if so we look it up and redirect the user to that item. I think it's easier to catch 404 errors using the IIS settings than it is to try to catch the 404 in the Global.asax. I think this is what you are asking. Steve West Lead Architect - ProjectInsight.net Web-Based Project Management Software http://www.projectinsight.net
Thanks Steve- I tried out your solution.. unfortunately with no luck. I went to inetmgr and clicked on properties on the virtual folder. There I changed the 404 settings to a custom page. However, if I still do something like this: http://server/dir/~nested/page.aspx (note the '~'). I still get this error (shown below). It seems like the aspnet engine is trying to process this url and failing. I am trying to find where I can catch this exception. Using global.asax or HTTP modules does not work. However, I have been able to handle a url like this: http://server/dir/nested/~page.aspx using the global.asax Application_Error Stack Trace: [HttpException (0x80070057): Invalid file name for monitoring: 'c:\inetpub\wwwroot\services\~ErrorWS'. File names for monitoring must have absolute paths, and no wildcards.] System.Web.DirectoryMonitor.AddFileMonitor(String file) +429 System.Web.DirectoryMonitor.StartMonitoringFile(String file, FileChangeEventHandler callback, String alias) +76 System.Web.FileChangesMonitor.StartMonitoringPath(String alias, FileChangeEventHandler callback) +495 System.Web.Caching.CacheDependency.Init(Boolean isPublic, Boolean isSensitive, String[] filenamesArg, String[] cachekeysArg, CacheDependency dependency, DateTime utcStart) +1535 System.Web.Caching.CacheDependency..ctor(Boolean isSensitive, String[] filenames, DateTime utcStart) +50 System.Web.Configuration.HttpConfigurationSystem.GetCacheDependencies(Hashtable cachedeps, DateTime utcStart) +144 System.Web.Configuration.HttpConfigurationSystem.ComposeConfig(String reqPath, IHttpMapPath configmap) +697 System.Web.HttpContext.GetCompleteConfigRecord(String reqpath, IHttpMapPath configmap) +434 System.Web.HttpContext.GetCompleteConfig() +49 System.Web.HttpContext.GetConfig(String name) +195 System.Web.CustomErrors.GetSettings(HttpContext context, Boolean canThrow) +20 System.Web.HttpResponse.ReportRuntimeError(Exception e, Boolean canThrow) +39 System.Web.HttpRuntime.FinishRequest(HttpWorkerRequest wr, HttpContext context, Exception e) +486
-
Thanks Steve- I tried out your solution.. unfortunately with no luck. I went to inetmgr and clicked on properties on the virtual folder. There I changed the 404 settings to a custom page. However, if I still do something like this: http://server/dir/~nested/page.aspx (note the '~'). I still get this error (shown below). It seems like the aspnet engine is trying to process this url and failing. I am trying to find where I can catch this exception. Using global.asax or HTTP modules does not work. However, I have been able to handle a url like this: http://server/dir/nested/~page.aspx using the global.asax Application_Error Stack Trace: [HttpException (0x80070057): Invalid file name for monitoring: 'c:\inetpub\wwwroot\services\~ErrorWS'. File names for monitoring must have absolute paths, and no wildcards.] System.Web.DirectoryMonitor.AddFileMonitor(String file) +429 System.Web.DirectoryMonitor.StartMonitoringFile(String file, FileChangeEventHandler callback, String alias) +76 System.Web.FileChangesMonitor.StartMonitoringPath(String alias, FileChangeEventHandler callback) +495 System.Web.Caching.CacheDependency.Init(Boolean isPublic, Boolean isSensitive, String[] filenamesArg, String[] cachekeysArg, CacheDependency dependency, DateTime utcStart) +1535 System.Web.Caching.CacheDependency..ctor(Boolean isSensitive, String[] filenames, DateTime utcStart) +50 System.Web.Configuration.HttpConfigurationSystem.GetCacheDependencies(Hashtable cachedeps, DateTime utcStart) +144 System.Web.Configuration.HttpConfigurationSystem.ComposeConfig(String reqPath, IHttpMapPath configmap) +697 System.Web.HttpContext.GetCompleteConfigRecord(String reqpath, IHttpMapPath configmap) +434 System.Web.HttpContext.GetCompleteConfig() +49 System.Web.HttpContext.GetConfig(String name) +195 System.Web.CustomErrors.GetSettings(HttpContext context, Boolean canThrow) +20 System.Web.HttpResponse.ReportRuntimeError(Exception e, Boolean canThrow) +39 System.Web.HttpRuntime.FinishRequest(HttpWorkerRequest wr, HttpContext context, Exception e) +486
Where is this coming from? avneeshb wrote: System.Web.DirectoryMonitor.AddFileMonitor(String file) +429 System.Web.DirectoryMonitor.StartMonitoringFile(String file, FileChangeEventHandler callback, String alias) +76 System.Web.FileChangesMonitor.StartMonitoringPath(String alias, FileChangeEventHandler callback) +495 System.Web.Caching.CacheDependency.Init(Boolean isPublic, Boolean isSensitive, String[] filenamesArg, String[] cachekeysArg, CacheDependency dependency, DateTime utcStart) +1535 System.Web.Caching.CacheDependency..ctor(Boolean isSensitive, String[] filenames, DateTime utcStart) +50 System.Web.Configuration.HttpConfigurationSystem.GetCacheDependencies(Hashtable cachedeps, DateTime utcStart) +144 System.Web.Configuration.HttpConfigurationSystem.ComposeConfig(String reqPath, IHttpMapPath configmap) +697 System.Web.HttpContext.GetCompleteConfigRecord(String reqpath, IHttpMapPath configmap) +434 System.Web.HttpContext.GetCompleteConfig() +49 System.Web.HttpContext.GetConfig(String name) +195 System.Web.CustomErrors.GetSettings(HttpContext context, Boolean canThrow) +20 System.Web.HttpResponse.ReportRuntimeError(Exception e, Boolean canThrow) +39 System.Web.HttpRuntime.FinishRequest(HttpWorkerRequest wr, HttpContext context, Exception e) +486 It looks to me like you are possibly handling the invalid request and that the folder path is is not clean for the start monitoring path. Is this IIS code? It looks like your code. I just tried a "~" on my system where we handle invalid URL's through the error page and it didn't create any errors. Steve West Lead Architect - ProjectInsight.net Web-Based Project Management Software http://www.projectinsight.net
-
Where is this coming from? avneeshb wrote: System.Web.DirectoryMonitor.AddFileMonitor(String file) +429 System.Web.DirectoryMonitor.StartMonitoringFile(String file, FileChangeEventHandler callback, String alias) +76 System.Web.FileChangesMonitor.StartMonitoringPath(String alias, FileChangeEventHandler callback) +495 System.Web.Caching.CacheDependency.Init(Boolean isPublic, Boolean isSensitive, String[] filenamesArg, String[] cachekeysArg, CacheDependency dependency, DateTime utcStart) +1535 System.Web.Caching.CacheDependency..ctor(Boolean isSensitive, String[] filenames, DateTime utcStart) +50 System.Web.Configuration.HttpConfigurationSystem.GetCacheDependencies(Hashtable cachedeps, DateTime utcStart) +144 System.Web.Configuration.HttpConfigurationSystem.ComposeConfig(String reqPath, IHttpMapPath configmap) +697 System.Web.HttpContext.GetCompleteConfigRecord(String reqpath, IHttpMapPath configmap) +434 System.Web.HttpContext.GetCompleteConfig() +49 System.Web.HttpContext.GetConfig(String name) +195 System.Web.CustomErrors.GetSettings(HttpContext context, Boolean canThrow) +20 System.Web.HttpResponse.ReportRuntimeError(Exception e, Boolean canThrow) +39 System.Web.HttpRuntime.FinishRequest(HttpWorkerRequest wr, HttpContext context, Exception e) +486 It looks to me like you are possibly handling the invalid request and that the folder path is is not clean for the start monitoring path. Is this IIS code? It looks like your code. I just tried a "~" on my system where we handle invalid URL's through the error page and it didn't create any errors. Steve West Lead Architect - ProjectInsight.net Web-Based Project Management Software http://www.projectinsight.net
This is the message thrown when I try to browse the link using explorer. So, it is the ASP.NET engine that is producing the message. The thing I am not sure about is that is this a 404 error at all? Just to confirm: You are handling 404 errors in IIS by redirecting to your own aspx page in the IIS settings.. is that correct?