How to make Asp.Net ignore my physical directory? - asp.net

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.

Related

MVC6/ASP.NET core published to iis 404 on controller endpoints

I have managed to publish an MVC6 website to IIS, but it seems to be only serving the static files in wwwroot. As soon as I make a request to a MVC controller endpoint I get a 404.
What other steps do I need for the backend code to run? I see that in the web.config it is executing the web.cmd file in approot, but this doesn't seem to be running.
Edit Running the web.cmd directly - i.e. using the self-host ability - works fine on the server where the app is deployed.
I had a similar issue to this (404 on every page except for root) and while initially it looked like an IIS configuration issue or a problem with httpPlatformHandler, after running web.cmd manually I was able to find some issues with my connection string.
After fixing these issues I was able to run the site through IIS without any hassles.

ASP.NET WEB API 2 Works Locally But Not On Production Web Server

I've developed a new WEB API 2 that works great locally, however when I upload the same code to my production server (Arvixe in this case) all I get is a 404 when I call it. I've spent HOURS searching the web, reading forums, etc.. and have been able to find no resolution, so I'm asking here as my last effort.
I'm currently only testing with the default project that gets created when you do New Project > ASP.NET Web API 2 Empty Project in Visual Studio. This creates an empty project with a single ValuesController. You should be able the JSON response by called /api/values, but this doesn't even work.
I'm using Fiddler to test the API locally and on the web server.
http://localhost:1993/api/values <--- works great
but
http://api.mydomain.com/api/values <--- returns 404
Note: I created a subdomain "api" in this case, but everything for the code for the API is unchanged from when it was created.
Why in the world does this work locally but not on the production web server?
That the server returns 404 (Not Found) may indicate a lot of things. However you can check using the following step:
Add a simple text document like readme.txt to your a folder sub-domain http://api.mydomain.com, and try to get access to that. If you can't access to that file, it means that the subdomain is not configured properly.
Publish the webservice using the "Publish" functionality, so that all DLLs will be copied.
After that,try to reach the Web ApI again.
Hope that help.
"Note: I created a subdomain 'api' in this case, but everything for the code for the API is unchanged from when it was created."
Above comment of your's is suspicious, you should publish your WEB API application in the root directory. Like if http://example.com is pointing to "MyExample" folder, then application should be published on "MyExample" folder.
After that you will be able access your api with http://example.com/api/{controller}/{action}
Just a simple suggestion which I'm sure you have already considered, but have you opened the http port 80 on the server's firewall?
Also stick a plain old html file in the root of your project and see if the server serves it up.
in your case, since you create a subdomain of 'api', you should try
http://api.mydomain.com/api/api/values
note that if you're using database for the function, you should change the connectionString in your web config
Please verify the .net framework on you hosted domain that may be old one.
Web api 2 is supposed on 4.5 framework.
One reason for web api 2 method working OK on local machine but not on production server is that the method you are calling is working on local machine but not on remote server. In such a case you will receive message 404 or 500, and you would be lost why this routing is failing.
Why a method would fail on remote server, well there may be many reasons. For me, I was querying database in my method and my connectionString was not set for remote server.
One way of resolving it would be to put some very simple code in that particular method and test that routing is working. Then check your original code for errors reasons.

HTTP 405 on Error on HTTP POST IIS ASP .NET

I'm working on a web application that is referenced from another, external application. The external application tries to do a POST on the vdir when opening. At this point, I get an HTTP 405 Error:
HTTP Error 405 - The HTTP verb used to access this page is not allowed.
Internet Information Services (IIS)
I checked the IIS event logs and I see that the external application tries to post, but I can't change permissions for a directory, since I need an extension.
Any ideas?
Make sure you are including the web page file name in the post URL (http://yoursite/app/Page.aspx instead of http://yoursite/app)
You may need to explicitly allow POSTs to the file type of your web page. See here for instructions of how to do it in IIS. (Those instructions are for IIS 6. For IIS 7 simply go to Handler Mappings, click Edit for the appropriate entry, click the Request Restrictions button, then go to the Verbs tab.)
Do you have a default document in the virtual directory that you are posting to? IIS will not allow POST commands to a folder, but it should still map the virtual directory to the default document. Also try removing the trailing slash.
http://forums.iis.net/t/1171316.aspx

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.

ASP.NET gone FUBAR on a production machine

Today we tried to put an ASP.NET application I helped to develop on yet another production machine. But this time we got a very weird error.
First of all, from all the ASP.NET pages, only Login.aspx was working. The rest just show a blank screen when they should have redirected to Login.aspx. The HTTP response is 200, but no content.
Even worse - when I try to enter the address of some inexistent ASPX page, I also get HTTP 200! Or, when I enter gibberish in some existing ASPX page code (which should have been accessible without login) I also get HTTP 200.
If I enter the name of some inexistent resource (like asdasd.jpg), I get the expected 404.
The redirect to login page is written manually in Global.asax. That's because the application has to use some alternate methods of authentication as well, so I can't just use Forms Authentication. I would suspect that Global.asax is failing, if not for the working Login page.
Noteworthy facts are also that this machine is both a Domain Controller and has SharePoint installed on it. Although the website in question is listed in SharePoint's exception list.
I would check the following:
Is the application within a virtual application or its own site and not just a virtual directory?
Does the application have it's own App Pool? If it does not then is the app pool shared by apps in a different .net version.
Is the .net version of the application the correct one? 1.1 or 2.0?
Do the files in the file system have the correct permissions to be accessed via IIS?
Have you performed an IIS Reset?
Create a stand alone test.aspx page within your folder that just displays the date/time and check it works.
Make this single test.aspx page perform an exception (eg. divide by zero) and see what the outcome is.
More information required.
What Op Sys?
What mode IIS running under?
What version of .Net?
What version of SharePoint?
(Why are you using your DC as a web host?)
Does it work on the other production machines you've deployed to?
If so what is different between this machine and the working ones?
Did you deploy the same way?
Are you sure your hitting the right machine?
Are you sure your hitting the right web site?
What ISAPI components are installed globally and for the web site?
Is .aspx mapped to the ASP.Net ISAPI filter?
Do you have any HTTP Modules or HTTP Handlers configured?
Can you change the global aspx to write out some messages so you can be sure the piece of code you interested in is reaching?
Anything coming up on the IIS log or the event logs?
Addition:
What version of .Net?
By the sounds of it the .jpg request is being dealt with by IIS directly which is why you get the 404, but the .aspx request is being dealt with by something else which except for you login page, is always returning 200.
Assuming .aspx is wired correctly to .Net the the order of processing is based on ISAPI filters (high to low then global before site), then the ASP.Net ISAPI Extension (sorry I said this was a filter earlier but it's actually an extension). Then we get into the ASP.Net pipeline based on your .Net configs, and calls the HTTP Application (which includes your global.asax code), any HTTP Modules followed finally by a HTTP Handler. Your ASP.Net web forms are just fancy HTTP Handlers.
However, the request can be responded to and terminated from any point.
Since your code works on other machines though, I'm tempted to point a finger at SharePoint if it isn't installed on the working machines. Is this SharePoint 2007? That is also an ASP.Net application (I don't think 2003 was).

Resources