What files can be downloaded from a website root directory? - asp.net

If i have a page on my website called blah.aspx then there will be another file there called
blah.aspx.vb
I can browse to blah.aspx but if I try to browse to blah.aspx.vb, I'll get 'file not found' page.
If I change the name of blah.aspx.vb to blah.zip it can be downloaded via the browser.
If I change the name to blah.qaz I'll get the 'file not found' again.
I suspect that the server will not allow the .aspx.vb file to be downloaded but if it doesn't protect a .zip file why does it protect a made up .qaz or is that just a shortcoming of the browser?
Are there file extensions that a server will actively protect?
Are there file extensions it deliberately won't hide (e.g zip)?
What are the rules and where can you find them?

IIS 7 maps 'allowed' extensions (or extensions that it will handle) in the applicationhost.config file.
If you really want to allow a 'qaz' extension, you could add a mimeMap to add it as static content. Don't know what webserver you're using, but if you're on II7+, you should be able to add it to your web.config:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".qaz" mimeType="text/plain" />
</staticContent>
</system.webServer>
</configuration>
If you're on an earlier version of IIS, then it's a different ballgame. If you're on some other webserver, you'll have to search around for the configuration information, but most will have some configuration file that states which extensions they are ok serving.

Related

IIS error 500.19 error when reading web.config

I am running IIS under Windows Server 2016 and I'm trying to run an ASP.Net core 3.1 application but I can't get past this error:
500.19 error
(The language in the picture is Hungarian, but it contains no useful information whatsoever, just an example)
Here is my web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\Minibizz.Routing.Web.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
What am I missing?
P.S.: The web.config was created by Visual Studio 2019.
The reason behind the issue:
That error message goes on to say what exactly is bad about your configuration file, hence you should refer the “Config Error” and “Config Source” sections. This problem occurs because of the ApplicationHost.config file or the Web.config file contains a malformed or unsupported XML element.
if you are using url rewrite rule then install url rewrite Extention of iis. Enable ANCM logging, ie. set stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout\" (I think the path needs to end by a backslash), then run the web app and see if something gets logged into the stdout folder. Verify that the log directory exists at the path referenced by the web config. If it does not, create it. The path shown in your config would place the "logs" directory in the root folder of the deployed site. Verify that the application pool has to write access to the logs directory.
Make sure you installed the .net bundle.check that you installed below iis feature:
You may also need to verify that the path to the dotnet executable exists in the deployment machine's environment variables. To check this, first find the path where dotnet.exe is installed. It is generally located in either C:\Program Files\dotnet or C:\Program Files (x86)\dotnet. Once you know the path, ensure that the path exists in your Environment Variables.
The web.config content seems to be correct. If you use a clean web.config copy, does the problem persist? If the issue can be solved by replacing web.config with clean configuration content, then the problem is exactly with this web.config. In this case, I suggest you remove parts of the web.config content to narrow down the issue. If the pages show correctly after you remove one section, then the problem is with that section. You need double-check what's wrong with the section and update the correct configuration.
If the problem remains even with clean web.config content, I suggest you access other pages in different folders in your site to see if the problem still exists.
you could refer this below link for how to publish asp.net core site in iis:
https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-3.1&tabs=visual-studio

How to Enable .MP4 File Video In IIS 7.5

I want to open file video but it not working
I'm tried enabled directory browsing.
Tried run aspnet_regiis.exe -i
Finally
How to open it? How to make it working? Thank you!
Hi i know is a old post but i hope that it can help you
1.- First create a folder into C:\inetpub\wwwroot example : resources
2.- Open IIS or windows + R and write inetmgr
3.- You'll see the folder you just created
4.- select the folder for this example "resources" and you'll see on the right all option to config
select and open "directory browsing" there's an option to change disabled/enable put it on enable and save changes
5.- Open browser and type the ip or url of your site and you'll see the files
6.- if you can't open the file check if the MIME Types and add the format of the resource.
This changes will be on Resources Folder or in the folder that you're working.
According to your description, I suggest you could add below config to set the MP4 mime map setting for your IIS web application.
<?xml version="1.0"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".m4a" mimeType="video/mp4" />
</staticContent>
</system.webServer>
</configuration>
More details, you could refer to below article:
https://blogs.iis.net/bills/how-to-add-mime-types-with-iis7-web-config

My website hosted in the local iis can't load images, js and other files

I am totally new to IIS and this is my first attempt to host one of my websites on my own machine's IIS server.
I installed IIS using Add windows features on or off feature and used aspnet_regiis -i to install asp on it.
Then I copied my website's content to wwwroot directory and I have a partially working website, because some fonts, images, js files and a webm file can't be loaded into the page and when I go to these files by url I get this error message:
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 should mention that I checked static content under common http features in Add windows features on or off but still I have the same problem
Thanks in advance for your help
UPDATE:
I used to have a host and domain and this website worked perfectly there, So it Not a website problem
UPDATE2
some pictures load ok and some don't.some fonts are ok and some don't.chrome's developer console states an 404 error message for missing files and scripts and when I go to them via url,I get the error message above(which indeed is a 404 error message)
UPDATE3
I added woff and webm formats to MIME types so now these types of files work.But still some javascript files won't work since they are using json I json format and json is not added yet to the list of MIME types
What can I do so that ALL TYPES OF FILES are allowed?
Modify your web.config like
<system.webServer>
<staticContent>
...
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
...
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>

IIS returns 404 not found for .mp4 files

I used hmtl video tag to play video . In my localhost video plays but when I published . It is not played.I have created project based on in ASP.NET.
I locally use like this method.
http://localhost:41563/files/Just.mp4
and When I published the url give me an error like this:
http://111.111.22.22:41563/files/Just.mp4
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
How can I solve this.
Check if you have IIS MIME Type for mp4 added for hosted site (or for the directory where you have your video files).
For the Win Server 2012 is is already there but for Win Server 2008 it is not included by default.
So, if you developed/tested on WinSer2012 and then deployed on WinSer2008 then you can have this issue.
The mp4 MIME settings are:
File name extension: .mp4
MIME type: video/mp4
The MIME type can be added via Web.config as well, just in case your IIS is on Azure:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
</staticContent>
</system.webServer>
</configuration>
https://blogs.iis.net/bills/how-to-add-mime-types-with-iis7-web-config

IIS Express won't download .coffee files

I just enabled source maps because, sure why not, I'd like to try them out. However, I'm finding that IISExpress will not download .coffee files so it doesn't work.
I'm sure it's a simple web.config modification, I'm just not sure which one. How do I configure it to serve these?
All of IIS Express's configuration is done through the configuration files; in this case you want
C:\Users\[user]\Documents\IISExpress\config\applicationhost.config
In that file, there's a list of all of the static content types that IIS Express knows about and is willing to serve. You just need to add your extension to that list. The list starts about 1/2 down the file, in this XML element:
<staticContent lockAttributes="isDocFooterFileName">
It should be pretty obvious what to do from there: just map.coffee files to the correct mime type.
<mimeMap fileExtension=".coffee" mimeType="text/plain" />
This element is found within the system.webServer element, which is one of the ones that supports delegation to individual web.config files, so you should be able to add a similar XML block to your project's configuration file:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".coffee" mimeType="text/plain" />
</staticContent>
</system.webServer>

Resources