VS 2019 v16.8 build, MVC forms and javascripts stop working - asp.net-mvc-5

Problem:
If I build the project with VS2019 v16.8.2 and run the webapp then some of the
forms on MVC page stop working (click on button with type="submit"
and nothing happen, doesn't send any request to server) and also
jquery validations on page stop working.
Found out:
This is happening if I allow optimalizations in webconfig by removing debug="true" (from <compilation debug="true" targetFramework="4.6.2"/>). If I build and run
app with debug="true", html forms and other things work fine.
Application info:
Azure Cloud Services (1x WebRole, 2x WorkerRole)
MVC version: 5.2.7.0
.NET Framework: 4.6.2
I am still at the beginning of investigation. Have anyone the same experience or have you already found the solution?
I build and deploy app using Azure DevOps and the build is also make by the newest version of VS2019 and I have this bug also in Production.
A few weeks ago I was struggeling with another bug related to new version of VS2019 16.8 that caused failing build for Nuget lower than 5.8.0 so there is probably more issues with the new VS version or .NET 5.0 SDK.

Related

migrated .net core 2.2 app to 3.1 and it won't serve up in Azure

I have everything working locally, I have updated my build/deploy pipeline in Azure Dev Ops and everything builds and deploys fine however, when I call the site on my app service I get this error:
I have tried to find on the app service configuration page the place to change the .net core version (found this resource: https://www.hanselman.com/blog/UpdatingAnASPNETCore22WebSiteToNETCore31LTS.aspx) but I don't see any place to change the version - just the stack type. See 2nd screenshot:
Where do I need to go to update this to version 3.1? All other searches I"ve tried are coming up empty.
Confirm that the ASP.NET Core Extensions are installed. If the extensions aren't installed, install them manually:
1.In the DEVELOPMENT TOOLS blade section, select the Extensions blade.
2.The ASP.NET Core Extensions should appear in the list.
3.If the extensions aren't installed, select the Add button.
4.Choose the ASP.NET Core Extensions from the list.
5.Select OK to accept the legal terms.
6.Select OK on the Add extension blade.
7.An informational pop-up message indicates when the extensions are successfully installed.
After install ASP.NET Core 3.1(x64) Runtime Extension, then you will load your webapp successfully. Refer to this article to migrate from 2.2 to 3.1.

ASP .Net core project CI\CD fails in Publish using DevOps Project

We have an ASP.Net core 2.1 Devops project build and released successfully. But when we try accessing we are getting error.
HTTP Error 502.5 - Process Failure
If we take the drop from artifacts and try local it is working perfect. Please help!
After enabling stdoutLog, we got the following error details.
It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.App', version '2.1.0-preview1-final' was not found.
- Check application dependencies and target a framework version installed at:D:\Program Files (x86)\dotnet\ - Installing .NET Core prerequisites might help resolve this problem:http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
- The .NET Core framework and SDK can be installed from:https://aka.ms/dotnet-download - The following versions are installed:2.1.2 at [D:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]
Our application was using '2.1.0-preview1-final', seems Azure installed the latest version 2.1.2 for the DevOps environment. We updated our application with Core 2.1.2 and tried again. Now the application runs successfully without any error.
Thank you Martin Brandl!
Your best shot will be to enable logging to track down the error:
Go to the Kudu environment (https://YOURSITE.scm.azurewebsites.net)
On the top menu, select Debug console -> PowerShell
Navigate to site -> wwwroot and open the web.config
Set the stdoutLogEnabled attribute to true and save the file.
Create a folder named logs next to the web.config using mkdir logs
Now if you try to browse your site again, you should see a log file within the previously created directory containing additional information.
See also:
Determine whats wrong with your Azure Web / API App deployment

Asp.Net Core 2.0 on Azure results in a 502.5

I have a small web app developed with Asp.Net Core 1.1 deployed on Azure and it works well. I just migrated the project to use Asp.Net Core 2.0 and tried to deploy it on Azure. The deployment went fine but when I open the site, I get a 502.5 error. When I check my Azure log stream, I get the following error:
This error occurs when a CGI application does not return a valid set
of HTTP headers, or when a proxy or gateway was unable to send the
request to a parent gateway. You may need to get a network trace or
contact the proxy server administrator, if it is not a CGI problem.
Useless to say that it works well on my development machine with the same code. Note that I'm also using Entity Framework Core 2.0 although I deactivated the database creation on Azure (to check if it was not the cause).
For information, the way I migrated from 1.1 to 2.0 is by changing the target framework settings to "netcoreapp2.0" and by using the NuGet package "Microsoft.AspNetCore.All". Just to be sure, I also deleted my publish profile and recreate one.
Is it possible that Asp.Net Core 2.0 is not yet available on Azure ? I'm fairly new to Asp.Net Core, so I don't know when new releases are made available on Azure.
EDIT
When I try to run my app with dot net CLI via the debug console as proposed by natemcmaster, I got the following issue:
Unhandled Exception: System.IO.FileLoadException: Could not load file
or assembly 'Microsoft.AspNetCore.Hosting.Abstractions,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
The located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
I downloaded the DLL on my desktop and check the version with Dot Net Peak and indeed, the DLL is 1.1.2, although I created the project with Visual Studio and directly publish it, so is it an issue with Visual Studio ? Or Nuget ?
the issue was actually coming from the fact that, at first, my web app was using .net core 1.1, which deploys all the DLL in the "wwwroot" folder of the web application. However, with asp.net core 2.0, it does not do that anymore as the DLL are picked up from a global store. However, as Visual Studio does not clean the destination folder before a publish, I ended up with a situation where the 1.1 DLL were in my wwwroot, so the web site was picking up these ones instead of the 2.0 ones in the store folder.
This is explained in more details here: https://github.com/Azure/app-service-announcements-discussions/issues/2#issuecomment-313816550
Others have explained the reason why this is happening. I'd like to provide another – arguably easier – solution to the problem.
Just change the settings so that you remove files that are already on Azure – see below:
Check for log files either in the portal or by remotely accessing D:\home\LogFiles.
Sometimes, the logs won't indicate what is going wrong. Another good way to investigate further is to try launching your ASP.NET Core app from the Debug Console. If you are missing a shared framework version or there is another startup error, this will be more visible from the Debug Console.
Go to
https://(your web site name here).scm.azurewebsites.net/DebugConsole/
Your site will be in D:\home\site\wwwroot. You can launch it by executing:
cd D:\home\site\wwwroot
dotnet MyWebApp.dll
If you app still fails to launch, make sure that D:\home\site\wwwroot\web.config is available and configured to use ASP.NET Core Module. https://learn.microsoft.com/en-us/aspnet/core/hosting/aspnet-core-module
In my case, It was caused by having a space in the Project Name.
I can readily add a space, publish => 502.5.
Remove space, publish => good to go.
Hard to believe but I am duplicating it readily with above.
Also using "Remove Additional Files at Destination" per #Sam's Answer
See https://github.com/Azure/app-service-announcements/issues/14
"The rollout is expected to complete by Friday June 30th."
In my case the issue occurred because AppService at that time supported 2.0.0-preview2-006497 but I had 2.0.0-preview3-006890 installed which was used on build.
So I added global.json to use preview 2 SDK and it worked then
I don't know if this could help someone one day but in my case, I was using :
-Microsoft.AspNetCore.All 2.0.5
Downdrage to Microsoft.AspNetCore.All 2.0.3 resolve my problem
This happens when your version of ASP.NET Core cannot be matched on the server.
The simplest solution is to change your settings to deploy the app as self-contained, so it doesn't matter if Azure can match the framework version. Also, delete the files already on Azure, so you don't have issues when upgrading, as explained by #Sam.

TFS Build stopped running web deploy after .NET core install

I have had webdeploy running for YEARS on a Windows Server 2012 machine with standard MSBuild arguments (like this).
Yesterday I installed the Windows (Server Hosting) version of the .NET Core Installer from the .NET Core downloads page.
Since then my build tasks are running and successfully building my website, but not actually running any web deploy publishing. It is not failing - it is just not being run.
I want to stress I am talking about a 'legacy' .NET application - not a .NET Core application. I just installed .NET Core for somebody else.
I can verify this with the following observations:
There are no errors in any event viewers (except ones that are months old)
There is no message in the msbuild logfile that says Start Web Deploy Publish, however log files from just a couple days ago do have this message.
I can connect to the local server at port 8172 and it makes a connection.
It is happening with multiple projects that nobody else has access to.
_PublishedWebsites does get created with the latest files - it just never gets deployed anywhere.
What could possibly have broken this? Did the Windows Server Hosting package break it - or was it just some other update that came in? I've run out of ideas how to fix it and don't want to revert to xcopy!
Managed to fix it :-) Not sure exactly which of these steps did it, but I suspect it was Visual studio.
I was using TFS Express 2015 and upgraded to Update 3.
I also installed Visual Studio 2015 on the server itself.
I had previously had .NET Core RC2 (or whatever they called it at the time) installed and I uninstalled that before installing .NET Core RTM. Wondering if that removed some component that was required.
Like I said everything was working fine before I installed the .NET Core RTM - but fortunately installing VS and TFS brought everything back to normal.

Azure - error on starting with multiple web role projects

If I have more than one webroles(projects, not instances) in my application, I get this error: (I only get it if I attach a web role. It works fine wit as many worker roles projects as I want)
Microsoft Visual Studio
Windows Azure Tools for Microsoft Visual Studio
There was an error attaching the debugger to the IIS worker process for URL 'http://127.0.0.1:5100/' for role instance 'deployment(21).CloudPOC.WebRoleToHostDataService.0'. Unable to start debugging on the web server. The web server is not configured correctly. See help for common configuration errors. Running the web page outside of the debugger may provide further information.
Click Help for more information.
OK
What is wrong here? I can't understand it and I need a webservice project!
Make sure you are starting the Azure project rather than the Web Project itself. You might have set the Web Role as the startup project, and if you do that you'll find that IIS runs the Web App rather than the Azure Dev Fabric, meaning any Dev Fabric specific stuff (like config settings per role) aren't available causing problems.
What you're meant to do is let the Azure Dev Fabric (Compute Simulator) fire up all your roles for you, and it'll also work out if it needs to open a web browser etc.
So right click on the Azure Cloud project, set that as the Startup Project, and try again.
Hope that helps,
Andy
EDIT thought of something else!
Make sure your web.config is compiling to allow debug="true". If you have added a new WebSite to your solution, it won't be so by default:
<system.web>
<compilation debug="true" targetFramework="4.0" />
I had similar issue which got resolved with following steps.
Make sure you have correct version of .net framework 4.0 is intalled. (.Net Framework 4.0.30319 is the latest version)
Uninstall if there isany other .Net 4.0 framework in present on your system by going to Add And Remove programs.
Go to %windir%\Microsoft.NET\Framework64 physical location and remove unwanted .Net framework 4.0 folder
I've also had this problem and it happened when I upgraded my app to 4.0... I ran without debugging and got the following error:
There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined
and after researching that error, I found this:
http://forums.asp.net/t/1571308.aspx/1
which says there's currently a bug w/ vs2010 and 4.0... I took the answers recommendation and commented out the extensions section and it worked for me... Another possible solution.

Resources