1

I'm having some difficulties with my custom URL-rewriting setup. I'm not using any 3rd party tool to manage this, just using the global.asax by looking at every request and processing it.

The way I am using it is like: www.mydomain.com/site/google.com

This page contains information about the site "google.com". I'm using the actual domain within the URL. This is all works fine.

I have simplified the code that I'm using just to show you an example of how it works:

Dim myContext As HttpContext = HttpContext.Current
Dim URL As String = myContext.Request.ServerVariables("URL")
If URL.ToLower.Contains("/site/") Then
    URL = URL.Trim("/")
    Dim strURL As String = URL.ToLower.Split("/")(1)
    Redirect301("/site.aspx?url=" & strURL)
    Exit Sub
End If

The issue I'm having is for certain domain extensions, the page will just load up custom 404 Not Found and I have no idea what the cause is.

Example of pages that don't load:

  • /site/google.ad
  • /site/google.cd

I'm guessing that the system thinks that .cd and .ad files are actual physical files and when it doesn't find them, it shows the custom 404 error. It doesn't actually looks like the request is getting through to the global.asax. When working in local environment, they actually load fine but only on the live server it has this issue and this is why it has been a nightmare trying to figure it out.

Another issue I found was loading the following URL:

  • /site/prn.com

This shows a 404 error again but this time not the custom one I created but the actual hard looking .net 404 error page. This also works fine in local environment.

There must be some IIS setting or code change I could do to try to get this resolved.

Thank you for your time :)

Aki

Aki
  • 556
  • 7
  • 18
  • Does IIS have those extensions as MIMEs? – Rameez Ahmed Sayad Jul 16 '13 at 09:35
  • 1
    I think the Application.config for IIS blocks those extensions. Documents\IISExpress\config\applicationhost.config – Rameez Ahmed Sayad Jul 16 '13 at 09:38
  • That fixed the problem with the .cd & .ad extentions but do you have any ideas on why the /site/prn.com would show a hard 404 error: "The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. " – Aki Jul 16 '13 at 09:55
  • And this extension goes through Global.asax routing? – Rameez Ahmed Sayad Jul 16 '13 at 10:09
  • Yes it works fine on all other formats. For some reason just the /site/prn.com does this. For example, /site/rn.com works fine. It also works fine locally. it doesn't look like its hitting the global.asax at all though. It can't be anything to do with the extension this time. Very odd. – Aki Jul 16 '13 at 10:27
  • This is the error of the 404 page: "[HttpException] at System.Web.CachedPathData.GetPhysicalPath(VirtualPath virtualPath) at System.Web.CachedPathData.GetConfigPathData(String configPath) at System.Web.HttpContext.GetFilePathData() at System.Web.Configuration.CustomErrorsSection.GetSettings(HttpContext context, Boolean canThrow) at System.Web.HttpResponse.ReportRuntimeError(Exception e, Boolean canThrow, Boolean localExecute) at System.Web.HttpContext.ReportRuntimeErrorIfExists(RequestNotificationStatus& status)". It does look like it's treating it as a physical file.. – Aki Jul 16 '13 at 10:27
  • Since it's a .com extension , it would ideally treat it as a website and not a resource , now since you say the issue is only for prn.com , you can check the host file i.e. C:\Windows\System32\drivers\etc\hosts and see if by any chance prm.com is mapped to some other resource altogether – Rameez Ahmed Sayad Jul 16 '13 at 11:43
  • The file is empty. Out of thousands of pages I have, this one seems to be the only one suffering from this. – Aki Jul 16 '13 at 13:07
  • Maybe you could post a new question , if someone else could help ... I seem to be out of ideas . sorry – Rameez Ahmed Sayad Jul 17 '13 at 04:21
  • 1
    I found the fix for anyone having same issue: http://stackoverflow.com/questions/987105/asp-net-mvc-routing-vs-reserved-filenames-in-windows – Aki Jul 22 '13 at 01:57

1 Answers1

1

Check this link . Error message when you try to browse a Web page that is hosted on IIS 7.0: "HTTP Error 404.7 – FILE_EXTENSION_DENIED

This is the reason .ad .cd extensions are blocked.

Rameez Ahmed Sayad
  • 1,300
  • 6
  • 16
  • 29
  • Quick response and a great answer. I knew it had to do with some sort of IIS setting :). The problem I have left is the /site/prn.com still shows the hard 404 error. Any ideas? – Aki Jul 16 '13 at 09:49