MVC 3 Application on Server always gives 500 error - c#

I am bin deploying a MVC 3 site... it works fine on our 'Staging' server, which "theoretically" mirrors our "QA" server. However, when deployed to QA, it just gives a 500 error when trying to access it from the web browser. We've turned detailed errors on in the web.config, turning off friendly http errors in IE, but nothing.
Any suggestions on what we might check for? I've already verified that .NET 4 Client & .NET 4 Extended are installed on the server. I need to compile a checklist of possibilities. Scratching my head hard on this one...
UPDATE:
I noticed one oddity here, running the powershell command:
test-path "$<Env:ProgramFiles(x86)>\Microsoft ASP.NET"
returns false. As I said before, .NET 4 (Client & Extended) are installed, but nothing else. I find this a little suspect...

Log into the server's desktop and open the web-site from the browser there. You should then see the actual exception details.

This is going to take some troubleshooting on your part.
But, I would check the following, it sounds like it involves one of these guys:
web.config
machine.config
make sure all .dlls are installed (check the GAC)
make sure your IIS pool isn't wrong version
These are only a few off the top of my head. Hope it helps.

Agree with #Andrew, knowing the exception would really help.
Just to make sure, you've tried setting the customErrors element in your web.config to Off right? This way the exception details will show everywhere instead of a HTTP 500.
Try changing the AppPool that your site uses is set to .NET 4 Integrated
You could also try running aspnet_regiis.exe to re-register .NET with IIS.

This sounds like customErrors and httpErrors setting issue. Also check IIS permission/trust levels are configured properly.

Related

C# ASP.NET TempData was working but now it isn't on 2 of 3 computers

I'm working on a .net Core MVVC project devloped in VS Community 2017 and using IIS Express 10 and I'm having issues with TempData not working on two of the 3 computers I develop on. At one point it did work on all three.
I use TempData to store info during redirects and then transfer TempData to ViewData to display on the View page. I had issues with something (I don't remember what it was now) and was getting help from a co-worker and during his troubleshooting a box popped up and said something about SSL and I don't remember what he clicked but since then TempData stopped working. The one thing I think he did do differently than me was along the top in the Debug area, he clicked the IIS Express dropdown and chose the project name option instead. TempData now shows up as null after the redirect. When I open up the project on my home computer, TempData works with no issues. I have a 3rd computer I do some development on and it used to work on that until the SSL box popped up on that as well and it stopped working. I'm guessing that it's redirecting to the page I want but it's making a pit-stop somewhere along the way and the data is lost.
I tried uninstalling and reinstalling both VS and IIS Express with no change. I also tried deleting the .vs folder in the solution with no change. I tried clearing out the websites using the IIS Express command in the command prompt. I also tried it in both Chrome (where it used to work) and Internet Explorer with no change. I've tried running it with debugging and without debugging with no change.
So, TempData no longer works on two computers (both Windows 10 if it matters) and my home computer (Windows 7) works just fine. Anyone have any ideas?
by close look to your question, at first
"a co-worker and during his troubleshooting a box popped up and said
something about SSL and I don't remember what he clicked"
mybe your co-worker enabled ssl on development environment and after run the project you have to trust local IIS certificate.
I think you have to config cookie for using SSL for example <httpCookies requireSSL="true" /> or you can disable SSL for development and every thing gonna be OK.
for sure you can check that in home computer your URL have HTTP and in other two computers the URL starts with HTTPS.
On the other hands I suggest you to compare the web.config structures.
I found the answer finally at https://github.com/aspnet/Mvc/issues/8233
To fix the issue, I modified my Startup.cs file so that app.UseCookiePolicy(); was placed after app.UseMvc();. I don't know why it only affects one of my computers but it fixes the issue.

IIS serving static files despite my attempts to stop it

So, I've been working on project that's making use of the Katana/Owin pipeline. And I'm trying to use Owin to serve static files securely. Now, when I run the project locally through VS, everything works perfectly fine.
However, when I deploy it to a server (Windows Server 2008 R2, IIS 7), IIS has decided that it'll be damned before it lets any dirty managed handler manage its static files. Even when I've removed the static file handler. Even when I've added my own handler for a specific path. Even when I've told it to run All Managed Modules For All Requests. And since the path that's being passed in is a virtual path, IIS of course craps out and dies and either spits out a 500 or a 404 error. I'm not entirely sure what causes it to spit out a 500 over a 404, but anytime the request is deeper than 1 directory deep it gives out a 500 over 404. (/Client/Content/Folder/static.html(404) vs /Client/Content/Folder/SubFolder/static.html (500))
I'm just not sure where to go from here, at all. Worse still, when I've deployed to my local IIS (not running it out of VS, that is.) it works perfectly. It respects the web.config, the Owin middleware handles the static requests perfectly, the security is in place. Everything is peachy. Granted I'm running IIS 8 express on my box, but I'm not convinced that that is it.
I'm going to post my comment as an answer since the more I think about it, the more sure I am that it could be the issue.
Check that all necessary asp.net and IIS features have been installed correctly via Programs and Features - do a comparison between your dev and server environments. I've experienced essentially the same issues as yourself and this was usually the reason.
If this isn't the reason, check the IIS settings/Application pool settings make sure they are the on dev and production environments.

Random HTTP Error 403.14 - Forbidden [duplicate]

This question already has an answer here:
.cshtml files not working IIS [closed]
(1 answer)
Closed 8 years ago.
Randomly while coding an ASP.NET MVC site I started getting HTTP Error 403.14 - Forbidden errors, and when going to specific pages ("/Views/Default/Index.cshtml"), I get
The resource cannot be found. Description: HTTP 404. The resource
you are looking for (or one of its dependencies) could have been
removed, had its name changed, or is temporarily unavailable. Please
review the following URL and make sure that it is spelled correctly.
Requested URL: /Views/Default/Index.cshtml
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.32559
Which I guess means at least ASP.NET is being loaded, but why won't it recognize the page? I've tried so many reccomendations online, even went as far as removing the entry from IIS Express, then re-adding it through VS, copying the web.config from a working site to it, etc. Nothing seems to work - and it's only this one site. If I set directoryBrowse to true, I can get so far as a listing of all the pages & directories in my root. I can visit any of the directories except /Views/, which throws the same Resource can not be found error as above. I've also added directoryBrowse as true to the Web.config in /Views/, but to no avail.
Running the recommendation # http error 403.14- forbidden returns:
Microsoft (R) ASP.NET RegIIS version 4.0.30319.32559 Administration
utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation. All rights reserved. Start
installing ASP.NET (4.0.30319.32559). This option is not supported on
this version of the operating system. Administr ators should instead
install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Win dows
Features On/Off" dialog, the Server Manager management tool, or the
dism.e xe command line tool. For more details please see
http://go.microsoft.com/fwlin k/?LinkID=216771. Finished installing
ASP.NET (4.0.30319.32559).
I'm on Windows 8 with Visual Studio 2013 preview, and this has been working ever since about an hour ago, where it randomly started happening. I have a Global.asax file, and everything seems to be right (though obviously there's something off). I've getted the latest checkin to a new folder and ran from there, same problem. This is only one site, a site that was working perfectly just two hours ago. The only thing I can think of was that I was editing the routes when this happened, but I've changed the routes right back to what they were before and I'm having the same problem.
I'm at a complete loss as to what's happening, can anyone provide any kind of guidance? I'm willing to try/do/test whatever you need, I'd just like to figure out what's happening. Thank you so much, hopefully someone can figure out what's happening (and sorry about the lack of info on what I've tested and stuff - literally everything I saw in the past hour and a half of searching I've tried).
I really, really hate it when that happens - after an hour or two of searching, I find the answer seconds after posting on SO -.-
Anyways, I had to add HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents
I'm still at a loss to explain how this randomly happened - I wasn't editing anything close to web.config when the error started - if anyone could provide some insight into that I'll accept their answer.
I know this was asked a year ago, but I just had this problem and I just found the reason for it.
I don't have an IIS Server running in my computer so I can`t change its configuration. When I debug my code, it seems Visual Studio 2013 runs a server of its own for debug purposes.
Anyway, I also started getting these random HTTP Error 403.14.
In the Solution Explorer Right Click on your project and choose Properties.
in the Properties Window, go to Web and you`ll see it is defaulted to Start Action at Current Page.
The reason debug sometimes work and sometimes does not is because sometimes you have the correct asp page selected at the time you press debug button, and sometimes you are at the wrong asp page. That`s all.

How to find the deadlock in ASP.Net Website

I am using .Net 2.0 and my site seems to reach the deadlock state at certain period. It stops working until I recycle the application pool or change something in web.config file. I think deadlock is causing this issue.
I am wondering if there is any tool to debug/check the site to find the code that could be causing the deadlock.
Right now I had to set recycling interval to 10 minutes which is really bad but it is the only way to solve the problem and there is a lot of codes on the site and I need to find the problem. If I use DOS attack tool, can I find the page/code block that is causing this issue? If I can, what is the best tool to test it?
Cheers!
EDIT
I tried to check the Event Logs and found the following warning. I don't know if it is issue will keep digging now.
Exception information:
Exception type: HttpException
Exception message: Request timed out.
Check the event log
Turn on Health Monitoring
If you use the 'Failed Request Tracing' and it'll produce a nice output which will then tell you what is causing the error, down to the module level. This will then give you the first step into where it's breaking down.
Have a read of this article on iis.net → Troubleshooting Failed Requests Using Tracing in IIS 7
I would attach visual studio to IIS and break the debugger when a deadlock occurs. You can then inspect the call stack of the running threads.
Code Project has a nice article on how to do IIS remote debugging.
Of course, you can very well set up up a test machine with a local IIS and local Visual Studio .NET and do this without the need to remotely debug.

Find out what is causing problem in IIS7

We have a C# web application, and the latest deploy doesn't work on our Windows Small Business Server 2008 (IIS7). The exact copy of that site runs fine on my Windows 7 machine (IIS7.5). The previous version and other builds still work on the Server 2008 R2 machine, but this itteration doesn't.
I've checked the W3SVC logs, but no requests are logged. I've checked the eventlog for errors, but no errors are logged. I also checked in fiddler, but the request just doesn't get a response as far as I can tell (Result column remains -)
When you open the url, the browser will just keep loading (no timeout).
Is there anything else I can check or enable to debug this IIS7 behaviour?
Thanks in advance,
Nick.
UPDATE
I published the application again & created a new site in IIS, and this new version works. While my the immediate problem is solved at this time, I would still like to know how to debug IIS7, see how it works & why it would keep loading infinitely.
First, I would drop a regular .html file into the sites directory. Then I would have a browser request that specific static file. This would bypass the .net engine and should be logged.
If for some reason it doesn't work and/or isn't logged then there are other things to check, let us know.
Assuming that it does serve the file and you are pointing to the correct machine then inspect your global.asax file and remove any type of error handling you might have. Also turn off the custom errors section of your web.config. Both of which could result in the server essentially spinning off into nothingness if improperly coded. If you have any type of additional threads you are spinning up on access, then see if you can turn those off or add additional logging.
Next, look in the HTTPERR logs to see if you can identify what's going on. These are located at
%SystemRoot%\system32\LogFiles\HTTPERR\httperr*.log
Info about this log file is at: http://support.microsoft.com/default.aspx?scid=kb;en-us;820729
If your app uses ADO then there is chance that depending where the build occurred on Windows 7 or not and whether SP1 is installed or not (at the time of the build) that your build is broken by some Micorsoft ADO-update contained in SP1 (see http://www.codeproject.com/Articles/225491/Your-ADO-is-broken.aspx).
If no requests are logged in the W3SVC logs then it probably means that IIS is not recieving the request at all - likely due to firewall configuration or similar.
You should diagnose why IIS is unavailable (for example by attempting to serve some static content) and then try again.
Try these:
re-register asp.net runtime with your IIS7
make sure the asp.net extension for the correct version is set to Allowed in 'ISAPI and CGI restrictions' in your IIS

Categories

Resources