ASP.NET MVC 4 on IIS 7.5, returns 404. Something to do with extensionless route mapping - asp.net-mvc-4

I have deployed an MVC 4 web-site to a Windows 2008 R2 server with IIS 7.5. .NET 4.5 is installed on the server.
The site works fine locally. All routing works fine. However, when I put it on the server, nothing works. I have confirmed that the DNS/binding is working by putting a static text file in the site and this works.
Here's a few things I've tried:
The default route / returns 403.13 - indicating directory browsing is disabled (correct). This should surely map to /home/index?
Any route (eg. /Organisation, Organisation/Index) simply returns 404.
Made sure all my DLLs are copied over (as per http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx)
I have tried/confirmed:
HttpRedirection is installed on IIS7 (as per http://support.microsoft.com/kb/2023146)
HttpErrors is installed on IIS7
All my DLLs are in place
Am I missing something? My next act of desperation is to install the full ASP.NET MVC 4 stack including Visual Studio Express, SQL Express, etc. just to see if it works. Which I really don't want to do. This is a production server!
Update:
I should add that the same site works on en equivalent configuration in-house, on a staging server.

I had this same issue. There's a hotfix you should try:
http://support.microsoft.com/kb/980368
It fixed the issue for me.

Related

Blazor .NET Core app not deploying on IIS

I'm trying to deploy a blazor app on IIS following the article below
https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-5.0&tabs=visual-studio
I've installed IIS version 10.0 using the following settings:
I then created the site and changed the application pool to No Managed Code
I created a new Blazor app and deployed it immediately without changing a thing (so I know there's not a problem with the code). Looking in the project properties it's using .NET Core 3.1
I noticed there was no web.config file when I built the Release version.
I copied the Release version to the website directory.
Browsing to the site gives me a 403.14 - Forbidden error.
I read in another article to try configuring the Mapping Handlers this was the current state of the handlers:
I added a module mapping like so:
I now get a 500 error:
The web.config file currently looks like this:
I then read to add this aspCore line to the configuration file:
After that it looks like it loads but with none of the formatting.
I assumed hosting a Blazor site on IIS would be a simple thing to do, would someone be able to point me to where I am going wrong?

Deploying Asp.net Core 3.1 does not work on Windows server

I have this Asp.net Core 3.1 developed on VS2019 preview.
basically it is a blazor server-side app with referenced assemblies and some nugets.
it runs fine on VS2019 and on my IIS after publishing to folder..
problem is when i move that folder to windows server machine with IIS installed and everything.
an error with 500 code appears.
one thing i noticed here..the log_error.txt file in the server it points out an exception
,and that exception -what ever it is- showing the error line of the startup.cs file with my laptop directory path !
i mean it shows this C:/mrmeeez/..../Startup.cs line 411
but this path does not exists in the windows server machine
it supposed to be F:/.... somthing/Startup.cs line 411
i don't know if it has something too do with the problem anyway..or maybe my assemblies and nugets not shipping correctly to the server
windows server machine is working fine , i tried blazor app template and it ran perfectly.
i need your help guys , Thanks !
Ok , i found it
i don't know for sure is this related to asp.net core 3.1
because i deployed asp.net core 2.1 months ago and it was fine
anyway i used the development exception page in the final publish to see what causing the error and showed this
UnauthorizedAccessException: Access to the path 'C:\Windows\system32\config\systemprofile\AppData\Local\ASP.NET\DataProtection-Keys' is denied.
and after searching for that i found the answer from a guy in github
it seems that the user IIS_IUSRS for this application pool -by default- does not have permissions to access that path
to solve this problem,either one of the two below:
1-Give IIS_IUSRS permissions to access the system files -NOT RECOMANDED-
2-Change the user of the your application pool to LocalSystem account in IIS by going to Application Pools -> Right-Click your app -> Advance Settings -> Process Model section then change Identity
Reference: https://github.com/dotnet/aspnetcore/issues/1983
Thanks!

ASP.NET Core web app response with 502 error

I'm investigating an issue with the asp.net core 1.1 web app.
We had to install the latest VS 2017 on the build server. And straight after that, all the deployed builds return 502 responses. Nothing changed in the app code or the referenced packages, however, many binaries are different after VS 2017 install. The deployment is done via FTP.
I also noticed there is now a small difference in Http response headers. API Response Headers used to have Server: Kestrel. But now, after installing VS2017, the deployed builds return Server: Microsoft-IIS/10.0. This probably explains 502 error, but why would the Server now switch to IIS?
Managed to fix it. The error is caused because IIS server (proxy) can't access AspNetCoreModule, the process that hosts kestrel. Usually, the reason is because kestrel in some trouble.
The solution starts with checking Application logs in Event Viewer on the server.
In my case it was:
Application 'MACHINE/WEBROOT/APPHOST/MyApp.API' with physical root '\servername\c$\inetpub\wwwroot\MyApp.Api\' failed to start process with commandline '"dotnet" .\MyApp.Api.Web.dll', ErrorCode = '0x80004005 : 80008083.
So, by googling the error code I've realised that the server didn't have the right asp.net core version (for some reason).
Downloaded the installer, works fine now! :)

'Bad Gateway' error when loading aspnetcore RC2 default website project

I am attempting to run the default ASP.NET Core Web Application (Web Application Template in VS 2015) via IIS.
I have followed the instructions from the docs here eg setting up a 'No Managed Code' application pool and pointing the Physical Path at the location of the web.config file.
When I attempt to browse to the website root, http://localhost I am getting this error:
HTTP Error 502.3 - Bad Gateway There was a connection error while trying to route the request.
Most likely causes: The CGI application did not return a valid set of
HTTP errors. A server acting as a proxy or gateway was unable to
process the request due to an error in a parent gateway.
The event viewer states:
Failed to start process with commandline 'dotnet ./bin/Debug/netcoreapp1.0/WebApplication2.dll', Error Code = '0x80004005'.
This error shows I have replaced the placeholders
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%"
in web.config with the required values
<aspNetCore processPath="dotnet" arguments="./bin/Debug/netcoreapp1.0/WebApplication2.dll"
(update: these placeholders are replaced when you publish)
As per the troubleshooting instructions I have installed .NET Core Windows Server Hosting Bundle and restarted the server.
Running from the command line via dotnet works
Wondering what to try now.
Ok I figured my issue out. I am pointing the physical path in IIS to the unpublished Visual Studio project root directory. This works in previous versions of .net (ie non dotnet core aspnet projects) but doesnt now.
If you really want this to work then you have to publish your app to a temporary folder and copy the Microsoft.AspNetCore.* binaries back into the bin\Debug\ folder along with the refs and runtimes folders
This is a generic error for when IIS can't find the specified .NET Core components ,and doesn't know where to forward requests. In addition to following the official IIS publishing guide, make sure you have:
Installed the correct versions from the download page for latest .NET Core releases
Specified the correct library versions (explicitly or with wildcards) in your project.json
Included a web.config file (preferably using the publish-iis tool), and that the <aspNetCore> key values have been replaced with local values (source, with examples)
I ran into this while setting up a Core 1.0.0 (final) website on a new Windows 2008 Server. Turns out I had mixed up some of the installers from my dev machine with newer versions, and had mismatched library versions (RC2 vs final). Reinstalling the Server Hosting package fixed the problem.
The key to troubleshooting was to get into the console and use the dotnet commands (and resulting error messages) to iterate until I had my site running from the console, since the IIS error page in the browser was useless. I also found some benefit in a few entries in the system Error logs, but not much.

ASP.net 4.0 default.aspx problem on IIS6

I installed .net framework 4 on my windows 2003 enterprise x64, wrote simple asp.net 4.0 application (default.aspx page only). The application works great if request is to default.aspx, not to the root site:
contoso.com/ - doesn't work (Get 404 error)
contoso.com/default.aspx - works.
Default.aspx is in list of default documents in IIS.
Please help.
Found a fix in a seemingly unrelated location - try setting the "EnableExtensionlessUrls" registry key to 0:
ASP.NET 4 Breaking Changes -> ASP.NET 2.0 Applications Might Generate HttpException Errors that Reference eurl.axd:
In the Windows registry, open the following node:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\4.0.30319.0
Create a new DWORD value named EnableExtensionlessUrls.
Set EnableExtensionlessUrls to 0. This enables extensionless URL behavior.
Save the registry value and close the registry editor.
Run the iisreset command-line tool, which causes IIS to read the new registry value.
You will find the answer here
http://johan.driessen.se/archive/2010/04/13/getting-an-asp.net-4-application-to-work-on-iis6.aspx
.Net 4.0 doesn't enable itself to run with IIS so you have to run the command (while in the folder c:\windows\system32):
cscript iisext.vbs /EnFile C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
or in your case since you are running x64
cscript iisext.vbs /EnFile C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll
Change the ASp.Net Version from 4.0 to 2.0 and apply it. and revert back The Asp.Net version to 4.0. This Will address the issue.
I don't have enough points to comment apparently, but I wanted to say that the solution from Will WM worked for me. Adding EnableExtensionlessUrls to the registry corrected the problem.
As a side note, if your run aspnet_regiis at anytime, it will remove this value and you will need to add it again.
I use the following regex as first rule with Ionics Isapi Rewriter for web sites running on ASP.NET 4 on IIS 6 to remedy the problems caused by the breaking change introduced with ASP.NET 4 :
RewriteRule ^(.*)/eurl.axd/[a-f0-9]{32}(.*)$ $1$2
This let me again use extensionless urls.
Note that the second group captures the querystring if present and restitutes it to the rewritten url.
And yes, it's a feature, not a bug.
Are you sure it's default.aspx not default.asp in the list of default documents?
You will also get this error on ASP.NET 2.0 virtual directories in IIS6 if you have another virtual directory on the same site that is set to 4.0 and the DefaultWebSite is set to use ASP.NET 4.0.
The solution is to change the DefaultWebSite back to the ASP.NET 2.0. Your 4.0 virtual directory will still do fine underneath that web site.