Cause of 403 after .NET6 and Publish - web-deployment

I'm trying to publish my ASP.NET application now that I have upgrade3d everything to .NET 6 and am getting a 403 error.
This application has been running for months or more on .NET 5 and I have published countless times without a problem.
The project has been upgraded (TargetFramework, etc.) all Nuget packages are at 6 and the Hosting Bundle for .NET 6 in installed on the server (dotnet --info verifies).
The app compiles and runs locally and the publish process (after fighting with it all day) seems to work-ish (with this latest problem being the end of the line (so far).
Anything I can check or change?

In my case, this was caused by the deletion (via publish + delete existing files option) of the web.config file (which I don't maintain locally (no need).
While it seems weird that the publish process doesn't generate or at least warn of the absence of this file, simply recreating it on the sever with very basic information resolved the problem for me.
I now keep a copy of that file handy and a note to replace it when I have a need to publish with delete.

Related

TeamCity using MSDEPLOY ERROR_FILE_IN_USE

I have an ASP.NET 4.6.1 application that I am trying to deploy to a remote web server using TeamCity and MSBuild. Below is the MSBuild build step within TeamCity.
When I run the build in TeamCity, it always fails on this build step with a FILE_IN_USE_ERROR. The DLLs that are being updated before the error are usually the same, but sometimes they are different.
[MSBuild output] Info: Updating file (MyApp\bin\roslyn\Microsoft.VisualBasic.Core.targets).
[10:35:23]
[MSBuild output] Info: Updating file (MyApp\bin\roslyn\System.AppContext.dll).
[10:35:23]
[MSBuild output] Info: Updating file (MyApp\bin\roslyn\System.Collections.Immutable.dll).
[10:35:23]
[MSBuild output] MSDEPLOY : error Code: ERROR_FILE_IN_USE [C:\BuildAgent\work\b89cd3dfa447b\MyApp\MyApp.csproj]
I've already read through many articles (here, here, here, and here) suggesting that I drop an app_offline.htm file before deploying so that the IIS can re-route traffic and the file locking issues will stop. I tried that and it doesn't work. I still get the file in use issues during this build step.
I've also read in plenty of other discussions that another solution is to stop the application pool, deploy the app updates, and start the application pool. This is not a realistic solution because the deployment usually lasts between 15 and 20 minutes. Plus, this doesn't allow me to show a nice message to any current users.
I've been reading about this for a while now and it seems like this is a common use case for deployment to an IIS web server. Shouldn't this just work without locking files? Does anybody know of any other solutions to this problem?
I would try by stopping app pool to see if that`s a root cause of the issue.
But I'm not sure why it fails on .csproj file, because usually you don`t deploy those on server. So either it fails on different file (that is actually in use by web application) or it fails during build, not deploy (than app-pool stop will have no affect).

Deploying an ASP.NET 5 Web App through ARM not working

I'm migrating an ASP.NET 5 Web App from manually deploying in Visual Studio to deploying through an ARM template. I can successfully provision the website and the deploy claims to succeed, but whenever I hit my endpoint I get a 404. It doesn't seem to be a configuration issue, as if I deploy the same web app into the same container through VS it works as expected.
Browsing through the files on the site, the only difference I can see is that there's no web.config when published through ARM, and I'm wondering if that might cause it.
The way the deploy seems to work is that ARM is calling "dnu pack" on my xproj to create a nupkg, and that deliberately strips out the web.config file. I get the following message:
The following commands will not be exported for global install: web.
I can't see any way of forcing "dnu pack" to include web.config.
Most of the documentation I can find refers to using a .zip file to upload, but that seems to be only for older versions of ASP.NET. Anyone got any pointers?

Unable to deploy ASP.NET 5 (ASP.NET Core 1) to Azure

I have a ASP.NET 5 (ASP.NET Core 1) solution here in GitHub which has multiple projects in it. I have been able to build and publish the project just fine on my local machine. But I am not able to publish the same project on my azure web app.
I tried this, this, this, this and a lot more. I tried doing direct ftp publishing, custom deployment scripts,just XCOPY command on the custom script to copy published files from repository to site folder in azure. But nothing seems to work.
The continuous deployment within azure gives me an error "could not find a part of the path while doing dnu publish in the deployment script of azure every time.
Even when I am directly copying and pasting the locally published files to azure site folder via ftp. The site won't run.
I just want to have the site deployed on azure and if possible with continuous integration.
I have spend 2 days trying to figure out a solution. And I have given up on it now. Any help and directions would be highly appreciated.
What .NET Framework version are you compiling against. Sometime back I ran into this and finding the real cause took me a bit. The cloud service guest OS are behind a bit see this.

How to troubleshoot app domain shutdown due to "change in app_offline.htm", after editing file in Visual Studio?

Every time I change a file in a web project in Visual Studio (.js, .css, .cshtml, whatever) my app domain immediately shuts down and restarts. The shutdown message (which I log) is "HostingEnvironment initiated shutdown / Change in App_Offline.htm"
This just started happening after months of normal development. I'm looking for an explanation, or suggestions for troubleshooting.
Relevant info:
This occurs after changing a file in the web project. I am NOT doing a compile.
ASP.NET MVC 3 with the T4MVC plugin
Occurs when I change a view or any content file [.js, .css] referenced by web project
Project is configured to use Visual Studio internal web server, but I am accessing the website via IIS. [Web site directory points to the web project directory on disk]
I do not have an app_offline.htm file, nor do I see one created for me
Files in /bin/ do not appear to be changed [timestamps don't change]
I am using NCrunch, but this still occurs with it disabled
This only occurs when I change a file in Visual Studio. Editing with text editor does not cause the app domain restart.
How do I figure out what Visual Studio is doing to cause this? This makes it very difficult to work on html/css/javascript, for obvious reasons.
It appears that uninstalling and then re-installing T4MVC fixed the problem.
This might be relevant: a few days before I noticed this app domain restart issue, something happened and created a second T4MVC.cs file [called T4MVC1.cs]. This caused compilation errors from things being defined twice, and deleting the original T4MVC.cs file fixed that problem.
When I uninstalled and reinstalled the T4MVC package from nuget, I modified the web.csproj file and updated the <LastGenOutput> element to have a value of "T4MVC.cs".
I don't know if the issues with the generated file were related to the app domain restart issues, but after removing and reinstalling the T4MVC package and restarting Visual Studio the issue has gone away.

Error running ASP.NET MVC on IIS 7

I have been trying to deploy my asp.net mvc site to IIS 7 and having a bit of an issue. Whenever I run the site, I get a "Could not load type 'System.Web.Mvc.ViewPage'.". When I try to access a page with a master page, I get a Could not load type 'System.Web.Mvc.MasterViewPage'" error. I tried using tracing rules in IIS 7 to narrow down on the issue with no anvil.
On the bright side, when I run the site through the built-in visual studio webserver, the site runs just fine but not on IIS 7. Has any one run into this before or has any idea what could be causing this error. Thanks.
OK, so after playing around with this issue for a while. I finally fixed it. I was publishing to IIS 7 using visual studio deployment tools with copy 'only files needed to run this application". For some reason, using this publishing configuration doesn't copy all the files needed for mvc to run correctly. When I changed my publishing setting to copy " all project files", it worked. I am yet to actually discover whats was missing between the two publishing configuration for one to error out but wanted to post the solution now just in case someone runs into the same problem.
You need to include the mvc DLL's by opening your solution, opening the references folder, right clicking on each of them, get their properties and setting them to Copy Local = true.
system.web.mvc
system.web.routing
system.web.abstractions
those are the three i think
Did you deploy all the necessary assemblies? ViewPage and MasterViewPage are in the same assembly.

Resources