IIS 7.5 doesn't run *.inc as ASP Classic - iis-7

I'm setting up an ASP Classic website on Win7 x64, I have done the usual trick (Add site as Application to enable global.asa, use Classic pipeline App Pool, Enable 32-bit Applications: True, Load User Profile: False, Enable Parent Paths: True, give Everyone full access to site files, use odbc 32), and the site is up and running for *.asp files. However, I have some files named as *.inc under Includes directory, and IIS doesn't seem to be able to process them.
When I try to access http://localhost//includes/myfile.inc, I got:
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
I tried to add a script map in Handler Mapping, similar to the one for *.asp: Request Path = *.inc, Executable = %windir%\system32\inetsrv\asp.dll, Invoke handler only if request is mapped to File, and in the ordered list this new mapping is on top. Now I got this error when request .inc:
HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by the static file handler.
Any ideas?

Why are you trying to load .inc files in the browser? This is not normal behavior. Those files are meant to be included in other files, such as the ASPs.
Blocking those files from being requested is protecting you from revealing your source code, which is what would happen if IIS did serve those files; it would just output their contents verbatum.

Related

Receiving IIS 500 error for static files when installed with Sitecore 7.2

Hopefully somebody can point me in the direction of a solution for this particular problem.
The Scenario (Sitecore 7.2 rev 140526)
I have a static 'index.html' file hosted in a folder (let us call it 'test') inside my Sitecore web application.
If I access the index.html file directly via a web browser, everything loads correctly.
However, if I access the directory (i.e. http://myweb.site/test/) I receive a 500 error.
The error message is binding to the default document correctly, as evidenced by the details in the error message.
UPDATE: I have been able to reproduce with a fresh 7.2 instance with the NTTData CDN Connector configuration file in place.
What I have tried already
To prevent Sitecore from serving it's 404, I updated IgnoreUrlPrefixes setting
The index.html file name is in the list of default documents for the site (and folder)
In order to bypass the ExtensionlessUrl handler for .NET and resolve a 404 error, I have re-ordered the Handler Mappings to place the StaticFile handler before the ExtensionlessUrlHandler handlers.
Running on the same IIS instance, I setup a separate site with the same files and the default document loading worked correctly.
I have verified that the folder in IIS has Anonymous Authentication enabled
I have tried providing the Everyone group with full control to the folder in NTFS permissions
I have validated that the folder and folder parents are not marked as 'Hidden'.
IIS Failed request tracing did not provide much, but I did notice the Sitecore Rewrite module changing the URL a few times in the handler pipelines to append a "?". Subsequent calls by the static module did not show any warnings or errors though.
I have reproduced with a blank Sitecore 7.2 instance by adding the NTTData CDN Connector configuration file
The error I am seeing
HTTP Error 500.0 - Internal Server Error
Module: DefaultDocumentModule
Notification: ExecuteRequestHandler
Handler: StaticFile
Error Code: 0x800703e9
Requested URL: http://myweb.site/test/index.html
Physical Path: C:\MyWebsite\test\index.html
Logon Method: Anonymous
Logon User: Anonymous
Any thoughts?
While I have not figured out why the CDN connector interferes with the loading of the static files, I have been able to resolve the issue using an approach from this answer.
Essentially, by running the subfolder as an application with a classic mode application pool and putting the static file handler mapping first, the CDN connector doesn't execute and everything works great.
I think I found the cause of this.
There is a processor that is patched just before the FilterUrlExtensions processor called CDNInterceptPipeline which attempts to convert the following via a url rewrite:
/path/to/file.ext!cf!a=1!b=2 to /path/to/file.ext?a=1&b=2.
This caused all number of problems in our solution, including the one you stated above, and for the CDN set up we're using we didn't even need it. It might be that you can safely remove it from the SitecoreCDN.config as we did.
Source: https://github.com/NTTDATA/SitecoreCDN/blob/master/Code/Pipelines/CDNInterceptPipeline.cs
I accidentally had a web.config in the folder. Deleted that. Everything worked.

web.config file not there in the root(/) directory

I was trying to run a .cshtml file but it gave an error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /index.cshtml
So I searched for the solution and found that I had to edit the web.config file which is in the root directory(here it is My Site), but there is no file like that there there is only an index.cshtml which I had created.
I searched even the IIS and the IIS Express folders in Programs Files\ but there was no file like that?
If you are using WebMatrix, maybe your mistake was the starting point choice.
If you want to create a new Web Pages site you must start from a template in the Template Gallery of WebMatrix. Pay attention that the Empty Site template differs from the Empty Site option outside the Template Gallery because the first holds the files (binaries, packages and the web.config too) that are needed.
As the server error suggests, .cshtml files are not served, the reason for this is because they are server-side files that make up your application, they are just one piece of a much bigger picture.
If you launched your web application in debug mode and the URL in the browser was something like http://localhost:2932/Views/Home/Index.cshtml, just drop the /Views/Home/Index.cshtml part of the URL.

HTTP Error 404.3 - Not Found ... while downloading .dae files on ASP.Net

When I try to access a file extension .dae on IIS server... I get this error:
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
Looks like I am not able to configure something on my IIS Server. Can somebody please direct me to the right places. I am using Visual Express 2012 for web.
Since directory browsing is disabled for you, only few file types are accessible for the client,
like scripts and images.
In order to allow other file types, try this link. don't forget to replace the dmg with dae of course.

Activate form authentication for CSV files in IIS7

I have a website on IIS 7. This website has a HttpModule with an AuthorizeRequest event handler.
This event does not fire for CSV files and I can access the file without logging in, I guess this is because IIS7 is not configured to require form autentication for CSV files.
How can I set this?
This will impact all files, but you can add a mapping to your server configuration:
Go to the properties of your website and click on "Handler Mappings".
In the upper right corner click, "Add Module Mapping".
Put "*.csv" in the Request Path.
Select "IsapiModule" for module.
Find the aspnet_isapi.dll in the framework folder of the appropriate .net framework you are using under Executable.
Give it a name.
Check the tabs in "Request Restrictions" for more options.
This should force any .csv request to parse through asp.net (thus invoking formsauthentication) before servicing the request.
EDIT: Alternatively you can add a wildcard script mapping as desribed here: http://learn.iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/
This will force authentication to all non-.net files (pdfs, docs, anything).
this answer explains how to achive what I was looking for.
I inserted in web.config the lines in chapter 3 and 4 of the referenced guide, and
changed ".htm" with ".csv", maybe someone can optimize the solution for *.csv files. but for me it does what I needed.

Custom VirtualPathProvider unable to serve URLs ending with a directory

As part of a CMS, I have created a custom VirtualPathProvider which is designed to serve a single file in place of an actual file structure. I have it set up such that if a file actually exists on the server, that file will be served. If the file does not exist, the virtual content stored for that address will be served instead. This is similar to the concept of serving a website from files stored in a database, though in this case the content is stored in XML files on the server.
This setup works perfectly when a request is made to a specific page. For example, if I ask for "www.mysite.com/foobar.aspx", the content that is stored for "foobar.aspx" will be served. Further, if I ask for "www.mysite.com/subdir/foobar.aspx", the appropriate content will also be served.
The problem is this: If I ask for something like "www.mysite.com/foobar", things begin to fall apart. If the directory exists on disk (and doesn't have a configured default page in IIS, such as index.aspx), I will get a "Directory Listing Denied" error. If the directory does not exist, I'll simply get a 404 - Resource Not Found.
I've tried several things, and so far nothing I've done has made a bit of difference. It seems as though IIS is simply noting the nonexistence of a directory (or default file in an existing directory) and serving up its own error code, without ever asking my application what to do with the request. If it ever did get to the application, I would be able to solve the problem, but as it stands, I'm quite lost. Does anyone know if there is some setting in IIS that is causing this?
I've looked for every resource I can find on the subject, and am coming up empty. I know this should be possible, because I have read tutorials on serving content from both databases and ZIP files. HELP!
p.s., I am running IIS6 and .NET 3.5
IIS will only pass a request to the ASP.NET process if it is configured to do so for the particular extension. The default is aspx, ascx, etc. In other words, if you request a .html file, ASP.NET will never see that HTTP request. Likewise for empty extension.
To change this behavior, add a wildcard mapping to the ASP.NET process. Load IIS Manager, go to the Properties for your web site and look at the Home Directory tab. Click on "Configuration" and there you will see the extension-to-applicaiton mappings.

Resources