ASP.NET VirtualPathProvider with Static Files Issue - asp.net

I'm running IIS 7.5 on Windows 7. My ASP .NET application uses a VirtualPathProvider. Most of the files (aspx pages) are returned and rendered fine by my VirtualPathProvider. Static files (css/images) are not. They yield a HTTP 404 error if I try to browse to them directly (or if they're referenced by my virtual aspx page)
I've verified my web.config has the correct handler registered for static file types.
What's weird is this:
If I try to browse to a non-virtual gif file (one that actually exists on the file system under the website root), it renders fine.
If I run using WebDev in Visual Studio instead of IIS, the virtual gif files render fine.
In debug mode, in VirtualPathProvider.GetFile, I can SEE my VirtualPathProvider returning a perfectly valid instance of my virtual gif file right before the page returns the 404 error...so I know my VirtualPathProvider is working just fine.
NOTE, when I say IIS, I don't mean in a deployed environment. I just mean switching the project settings to use IIS instead of WebDev.
Any ideas?
Thanks.

...and answer:
The problem I’ve run into a bunch, particularly with routing showing up, is that even with a wildcard map to ASP.NET, my static files end up with a 404 error code because routing is catching them, sending the requests to the MVC handler, and no route is found. Fail.
So, as a note to myself (and anyone else who’s doing something similar), here’s what I’ve found you need to do to get your VPP serving up static files.
First, you need to get the desired static file types mapped to ASP.NET...

Related

404 when trying to access web api

I have an application I'm deploying to azure.
It's a SPA app which uses REST API.
I placed the folder of the app in side the wwwroot folder.
when I try to access the API from my local machine i.e. my localhost:1979/api/auth/login
I can do it but after I place the files in the www folder - I get a 404
when trying to access:
domain.com/api/auth/login
I tried doing it on my machine on my local IIS and got the same error.
I'm sure it's a stupid thing like configuration but I can't figure it out.
Thanks for any help
Solved
Ok.
So I checked the issue on my local IIS and got the same problem.
The thing is, I created a directory inside an existing solution which have the web api + mvc.net and called the directory which contains the html i.e. mydomain.com/dist/index.html directly.
The solution was to send the html file via the controller so when a user comes in to the site, the home controller will send the html file and the ajax call from the JS file which was download from the html will succeed unlike getting the html directly.

Where does IIS look for files

Can anyone explain, please, exactly how .net works. I create a web site in Visual Studio and publish it to a local server to a folder at
D:\WebSites\Project1
I create a web site in IIS and provide the address of the folder containing the files for the web site. When I publish the site, using 'fixed naming and single page assemblies', all the .aspx files go in the folder on the D drive and a dll for each page goes in the bin folder inside that folder.
I would assume that when someone wants to view a page in their browser, IIS retrieves the file(s) required from the folder specified, they get processed and turned into html and sent to the browser.
Recently when someone clicked a button on a page that calls a web service - a file not found error was reported. Apparently
C:\Temp\bx5tn2js.dll
could not be found. The thing is - why did IIS decide to look in C:\Temp for a file?
And, in the error message was a load of references to xml serialization. What is being serialized?
This file looks like the compile files that asp.net generates on compile.
This folder can be setup on web.config on compilation session with the
tempDirectory="C:\Temp"
If you do not have set this option asp.net is use a default folder that is usually inside the asp.net directory, inside the windows folder. But if you have set this, and this folder did not have the correct permissions, then asp.net fails to compile the project, and you can get a message like that.

How to make Asp.Net ignore my physical directory?

I'm creating my first FubuMVC application. I've got a physical folder Demo and a route that should handle the "/demo" url. For some reason, when I try to debug it in Visual Studio, it issues a permanent redirect to "/demo/", and then returns HTTP Error 404.20 - Not Found (No default document). When I route the same action to /demostuff, everything works just fine. I noticed that my application startup scripts are fired on the first request, but it's somehow not routed to Fubu's HttpHandler.
I'm using IIS Express.

Getting 404 error in IIS when calling asp page

I have a problem with my asp.net 4.0 application. When I call it on the server, it works, but when I call it from outside the server, it gives me a 404 error.
The link I call the asp.net application from is the good one. Other asp.net 4.0 applications are working fine when called from outside the server. The other applications are in another folder though, but I do not see why it would work under a folder and not another one. There is no IP restrictions on the applications.
Anyone got that error int eh past?
Thanks
EDIT:
The app is configured as an asp.net 4.0 application. it is stored in a virtual directory.
This link works:
http://localhost/Phonebook/PhoneBook/default-defaut.aspx
this link does not : https://www.test.com/Phonebook/PhoneBook/default-defaut.aspx
A coworker and me found the answer. It's because the server I called on my url was supposed to have a rule redirecting the browser to the right url. So IIS7 on my test server was setted up right.
Theres several things to check.
That test.com is even going to your server. Put a file in the root directory 'test.txt' that IIS lists as the root folder for your site. ensure you can get to it.
Once you verify your root site folder WORKS for ex., www.test.com/test.txt then ensure you have a virtual directory /phonebook that contains a folder phonebook within it.
Seems overkill to be having to folders named phonebook. Try taking one of them out and pointing your web application to your
c:\whatever\phonebook\phonebook folder.
Make sure port 443 is bound to your app if you're using https, that could be your problem.

Problem adding a .asmx file to a custom subfolder within a DNN site in IIS7

I'm trying to add some web service (.asmx) functionality to a DNN 5.6 website.
I've added this using some code behind (which I've placed in /App_Code) and a .asmx file which I'd like to place in a new roor folder - /Services/MyService.asmx
This functionality works fine locally under cassini.
However, when I deploy to IIS7, then I get a 404 for the .asmx file.
Here are some of the experiments I've done:
If I move the file to the /DesktopModules/MyService.asmx then everything works fine - I can see the .asmx file and I can call the service functions without any problems.
If I turn directory browsing on inside IIS7, then I can browse to /Services and see the .asmx file - but when I click through to that .asmx file then I get 404.
If I add a gif file to /Services then I can see this without any problems
Has anyone got any suggestions about what might be causing this? I'm wondering if it's the friendly name code within DNN somehow picking this .asmx file up?
Yes, the friendly URL provider isn't going to allow that in DNN 5.6. In 5.6.2, there will be a setting to let you exclude URLs from the friendly URL provider, to let you get around this issue.

Resources