ASP.NET file compiled, still not found - c#

I have an asp.net (version 4) website, for which I made a copy of the default.aspx file to test an alternate design. Works perfectly on my dev PC (IIS 7.5 I think) but I get a "Page not found" error on the server.
The really strange thing is that when I wanted to troubleshoot this and renamed the file but forgot to change the CodeFile="default2.aspx.cs" in the first line of default2.aspx, I got an error saying that it couldn't compile. Which was correct, of course. But when I change that too so that it compiles, it goes back to the page not found error.
So if it can't be compiled, it's there.
If it compiles, it's not there.
What am I missing here?
PS. In the IIS logs I see 404s and sometimes 301s. I checked some explanations of 301 so I'd like to rule out the redirection as a possible solution. I don't redirect anywhere.

Still not sure where exactly the error was within FriendlyUrls, but getting rid of it solved the issue. So it was working on my dev machine with IIS 7.5, but IIS 6 on my rather old server seems to be incapable of handling FriendlyUrls. I don't really need that, so axed.

Related

ASP.NET Core or ASP.NET Core MVC solution fails to run, IIS Express throws HTTP Error 500.30 - ASP.NET Core app failed to start

I've been having this error happen on even the simplest "Hello world" ASP.NET Core web app in Visual Studio. (Win 10 Pro, IIS Express, VS 2019 CE.) Steps to reproduce:
Create a new ASP.NET Core or ASP.NET Core MVC solution in Visual Studio 2019. Select the options to generate the scaffolding code for the basic "hello world" app. It doesn't matter whether you target .NET Core 2.1, .NET Core 3.1, or .NET 5.0, the result is the same in the scenarios I attempted.
The project and solution loads and the source code is visible and looks correct. Press F5 to run it. App compiles but does not run.
Expected behavior: the "hello world" app loads.
Actual behavior: shows this error message in the web browser:
"HTTP Error 500.30 - ASP.NET Core app failed to start" (and some
troubleshooting steps, then) "For more information visit:
https://go.microsoft.com/fwlink/?LinkID=2028265".
Go ahead and follow that link, then use those resources to double-check that you have all the needed packages and your IIS is configured properly. Mine was all looking good on my machine, but still I was getting this error. I even tried reinstalling VS, the hosting bundle, IIS, etc. but to no avail.
NOTE: This issue is a little different than the "500.32 ANCM Failed To
Load DLL" or the "500.36 ANCM Out-Of-Process Handler Load Failure"
errors, but I also encountered those during my troubleshooting, so I'm
mentioning them here in case it helps someone else.
NOTE ALSO: you do not necessarily have a corrupted ASP.NET Core
Module as this documentation would have you believe.
Check the event logs, you'll find some errors in there, but those are not particularly helpful in diagnosing the issue in this case. In my case, it just says
"Application '/LM/W3SVC/2/ROOT' with physical root 'H:\Repo
(R;)\sandbox\AspNetCoreWebApp001\AspNetCoreWebApp001' failed to load
coreclr. Exception message: CLR worker thread exited prematurely"
and
"Application has exited from Program.Main with exit code =
'-2147450743'. Please check the stderr logs for more information."
They show IIS Express AspNetCore Module as the source. Vendor docs were not terribly helpful on this scenario.
Double check to be sure you've got your IIS configration correct, and that you have the right packages installed, including the .NET Core Hosting Bundle. If you don't, or if you're trying different configurations like I was during troubleshooting, then you might see the ANCM errors mentioned above. If you get those errors, here are two links that can help. I read those links and checked my machine carefully, multiple times. In my case, this was all correct and complete, and I still had the error.
Fight with the computer some more, call it some bad names, reinstall Visual Studio for the 3rd time, verify IIS settings for the 8th time, ask your friends for help, check SO and Google yet again. The simple hello world app still won't run, same error. It runs on another machine, so there's nothing wrong with the code itself.
This was the solution that eventually fixed it on my machine: I moved the solution to a different folder. HUH??? How could that possibly fix this issue, I asked. After more head-banging, I eventually arrived at the root cause: a semicolon in the path. Yup. In my case, I had been storing the solution in a directory called "H:\Repo (R;)". It turns out, even though the ; character is allowed by the Windows OS, the .NET CLR does not like it at all and doesn't know what to do with it. So it generates the unhelpful error message.
Try it out. Rename the folder of your "this should be working" solution to remove the semicolons, close and reopen the solution in VS, press F5 and watch it run. Or go to a working solution and rename the folder to contain a semicolon and watch it break the CLR.
I was curious whether any other special characters in a folder name would cause an issue, so I checked them all (on folders, not on filenames, but I'd expect a similar result for filenames too). Here's my exhaustive test:
Windows disallows these in folder names:
\/:*?"<>|
The solution will load and run when the path contains any of these special characters:
`~-_+=',.()[]{}!##$%&
However, having any of these characters in the path, while being allowed by Windows, will cause issues in the CLR or in Visual Studio:
; Causes "HTTP Error 500.30 - ASP.NET Core app failed to start"
^ VS fails to load the solution & shows error message as follows:
"The following files were specified on the command line: <the .sln file>
These files could not be found and will not be loaded."
A totally empty instance of VS loads instead.
I also tried creating a new "hello world" console app in VS under a folder containing a semicolon in the name, and guess what? That also fails to run. Though in that case, obviously there is no HTTP error from IIS. Instead, it says
"Failed to create CoreCLR, HRESULT: 0x80070057"
and throws a process exit code. Once again, it's the result of having a semicolon in the path, because removing that semicolon from the path and reloading the solution in VS allows it to run correctly. So the semicolon issue seems to be originating from the CLR and therefore is unrelated to IIS.
Here are some related posts regarding the root cause, which is not readily apparent for web apps running on IIS Express:
Failed to create CoreCLR, HRESULT: 0x80070057
https://github.com/dotnet/sdk/issues/13954
So, kudos to those authors for those posts which were very helpful in the RCA.
One would think that the special characters allowed by the OS would also be fair game to use in the path to your Visual Studio code. Oh well. Lesson learned.

IIS 7.5 error on a DLLImport call

I have an error running a asmx WebService that uses asp.net 2.0 on IIS 7.5. The webservice calls a method from a dll using the Dllimport call. The point where the call is made is where the error happens. However I get no exceptions, just ERR_CONNECTIO_RESET from any explorer.
What i've tried:
The dll is located in the right place, the bin folder. I tried moving
it to system32 and other locations. However if I change the name of
the dll on the DLLIMPORT call i do get an error of not locating the
dll, which means it does finds the dll, just crashes on the method.
I also used GetLastWin32Error() and got the message 127
ERROR_PROC_NOT_FOUND. Not sure if it's relevant, however is something
I tried too.
If I run the Webservice on debug from VisualStudio, I get no error on
the call. So the error is when running on IIS.
I also tried on a older machine with IIS 6 on Windows XP and I get no
error. This make me think it has to do with a security issue, because
when I created the website on IIS I got this screen:
IIS 6
And i haven't configurated any security options on IIS 7.5. So i tried this
http://forums.iis.net/post/2119656.aspx
Which are steps to configure the user with enough permissions over the folder. However, still no luck.
What i believe now could be, is something asociated to GOP (Group Policy Object). The pc I'm running this service is on a company network. I have admin rights and no firewall restrictions, however I don't know if IIS 7.5 uses something from a different user or needs different permissions.
All the other threads i've found don't have the right answer for me. Any help i could get is appreciated.
Finally after a week of dealing with this, I found the problem. After finding out there are some Logs I could check on C:\Windows\System32\LogFiles\HTTPERR i found the error code Connection_Abandoned_By_ReqQueue.
After some long investigation, I found out that the message means the program is droping because of memorry corruption (As seen on this post Connection_Abandoned_By_ReqQueue Problems ). The dll I'm using is quite old and the people who generated didn't make a version who handles memory the correct way (At least for IIS 7.5), so I'm stuck with finding another library to do that work, or using a server with IIS 6.

All DLLS in site fail to load, exception 0x80070057

My C# web application stopped working for no apparent reason, while a similar application on the same server still works. Looking for ideas what could be going on and how to fix it.
Yesterday I launched a build of the site with some minor updates. The server apparently went down during the build, because for a few minutes TeamCity displayed a message indicating the connection had been lost. However, it recovered and resumed the build.
After the build, I was no longer able to load the site. The home page now seems to be the only page that can load, and it displays incorrectly because the scripts and stylesheets fail to load. If I check the browser’s error console I find reports of multiple server error 500’s, where the referenced css and script files are failing to load.
The server is IIS on Windows Server 2008.
If I go to the server and open the site there, the page gives me error messages saying, “Could not load file or assembly ‘Antlr3.Runtime.Debug’ or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)).”
Initially it was reporting the same message for a different file, AntiXssLibrary. I removed that DLL from the project, and the site switched to complaining about antlr instead. It looks like the problem isn’t either DLL, but something else.
On my machine, a nearly identical copy of the same code works without problem. Another copy of the site on the same server, a slightly earlier version of our software, works just fine.
I deleted all of the temp files recommended for this error, redid the build, restarted the machine, and deleted the bin directory and repeated the build. I’m skeptical that uninstalling or reinstalling any versions of the .net framework would help, given that the other site works—any problem with the frameowkr ought to affect both of them.
I turned on assembly logging, which gave me lots of additional information that didn’t help at all.
Any suggestions what could be going on?
Edit: a link below suggests that the problem is corrupted temp DLLs, and that deleting and recompiling will replace them with good copies. That's plausible. But it seems like re-running the build ought to recompile if anything is going to.
Might there be some other way to force it to recompile / update the DLLs?

Error allowDefinition='MachineToApplication' beyond application level in asp.net

recently while working on asp.net application, i got below error:
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
i am sure the previous day it was working absolutely fine, however i guess this error occurs usually because of multiple web.config files, but i checked in my project, whole project contains single web.config files, can anyone please tell me what could be the reason for this error.
As the error suggests, You need to set up the directory you've placed the website in as a web application within IIS.
Thanks Nawaaz, i got the resolution, actually that was because i was opening website (using file-->open-->website) and not the solution, so i opened the solution and cleaned the solution and build it, and worked properly, thanks a lot for taking time to revert.

ISS error CS0433: name collision

In our application we've run into an error numerous times where we get error CS0433, which complains about a name collison in two separate dlls. This is an ASP.NET app developed in C# using webforms. It always complained about A TimeLog page. Anyone have advice for resolving this error?
I found a link in the MSDN that describes this error.
To summarize, a naming conflict can happen between the file name of a page (TimeLogTab.aspx) and the class in the code behind (public class TimeLogTab).
The link recommends renaming one of them. I changed my class to Time_LogTab and the error went away.
The error can happen intermittently: I'm using "Publish Web Site" for a VS 2005 Web Application Project with "Delete all existing files prior to publish" and then XCOPY-Deploy to the target IIS folder (which won't delete existing files there). Today I ran into that error for the first time (no new .ascx/.aspx files since weeks), but simply recompiling and redeploying the same project solved the problem.
The only difference: For the 2nd time, I hit the page causing the problem first. Now I'm wondering whether the exact click order really matters or rather whether an arbitrary unlucky click order effectively can crash an ASP.NET site?

Categories