Web API configurations work in debug but not in iis - iis

I'm making a Web API project and I'm using iis.
I made the project and then I needed to add bundling to it. I used system.web.optimization file and webgreas DLLs from the default MVC project that is created by visual studio. There was an error for the required version of the webgreas DLL and I had to add the following configurations to the web.config file and it all worked fine when debugging.
<runtime>
<assemblyBinding xmls="urn:schemas-microsoft-com:ASM.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="..." />
<bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
After publishing to iis the configurations I made just didn't allow the deployed server to run and the error pops up when you try to go to any path:
Directory does not exist
Parameter name: directory virtual path
My question is if runtime tag can or can't be used in iis and how to fix this and import the DLLs correctly. (Preferably without using nuget)

Related

How to fix error "ANCM In-Process Handler Load Failure"?

I'm setting up the first site in IIS on Windows Server 2016 Standard.
This is a NET Core 2.2 application. I cannot get the site to show.
I am getting this error:
HTTP Error 500.0 - ANCM In-Process Handler Load Failure
What can I change to clear this error and get my site to display?
My application is a dll.
I tested my application on the server through the Command Prompt with
dotnet ./MyApp.dll
it displays in the browser but only on the server itself with (localhost:5001/).
Using this method the site cannot be accessed from any other server.
When I set up the site through IIS, I get the In-Process error both on the server and from servers attempting to access the site.
At first I was receiving the Out-Process error. Something I read said to add this (hostingModel="inprocess") to my web.config
so I did but now I receive the In-Process error.
The site works fine when installed on my development server.
The Event Viewer shows this error for "IIS AspNetCore Module V2":
Failed to start application '/LM/W3SVC/2/ROOT', ErrorCode '0x8000ffff'.
This is my web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="RemoteOnly"></customErrors>
<identity impersonate="false" password="****" userName="****" />
</system.web>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="false" hostingModel="inprocess" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">
<environmentVariables />
</aspNetCore>
</system.webServer>
</configuration>
I had the same issue in .Net core 2.2. When I replace
web.config:
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
to
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
then it works fine.
Note: The same solution also works for .Net core 2.2 and other upper versions as well.
Open the .csproj file and under Project > PropertyGroup > AspNetCoreHostingModel, change the value “InProcess” to “OutOfProcess”.
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
Sometimes this is because multiple applications may be using same Application Pool
In such cases first application will work and other won't work
Solution is to create new application pool for each application.
I had the same error.
According to Microsoft(https://dotnet.microsoft.com/download/dotnet-core/current/runtime), We should install the 'ASP.NET Core Hosting Bundle' in our hosting server.
'The ASP.NET Core Hosting Bundle includes the .NET Core runtime and ASP.NET Core runtime. If installed on a machine with IIS it will also add the ASP.NET Core IIS Module'
After I did, The 'AspNetCoreModuleV2' installed on my server and everything works well. It didn't need to change your 'web.config' file.
For more info, in web.config, set
stdoutLogEnabled="true"
then check the logs folder. In my case it had nothing to do with project, publishing or hosting settings - it was my fault for not copying a file essential to my app. The error was simply "Could not find file "D:\Development\IIS Hosting Test\filename.ext"
For my particular issue it was the site permissions in IIS.
I edited the permissions to "Everyone" and it worked. I got the information from this page: https://github.com/aspnet/AspNetCore/issues/6111
I belive that IISExpress got messed up along the way.
Try the following:
'Clean Solution' from VS
Got to the solution folder and delete the .vs folder from there.
Build and run.
I faced with the same issue today, installing the following package on server is fixed the issue for me. If you have any previous version of Windows Hosting Bundle already installed on the server, you install the new one without restarting the server.
ASP.NET Core 3.1 Runtime (v3.1.11) - Windows Hosting Bundle
In my case updating .net core sdk works fine.
You can get this if you try to access the site using a IIS url but Visual Studio is setup to use IISExpress
See also
ASP.Net Core 1.0 RC2 : What are LAUNCHER_PATH and LAUNCHER_ARGS mentioned in web.config?
Long story short, the web.config is changed by Visual Studio when you switch between IIS and IISExpress. If you use an IIS url when it's setup to use IISExpress then the aspNetCore processPath will be wrong
Also, it's not uncommon to copy web.config files. You could get the same error if you don't change the processPath
I fixed this here Asp.Net Core Fails To Load - you need to specify that the program uses an in process or out of process model.
I changed my CreateWebHostBuilder to:
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var builder = WebHost.CreateDefaultBuilder(args);
if (env == EnvironmentName.Staging || env == EnvironmentName.Production)
builder.UseIIS();
builder.UseStartup<Startup>();
return builder;
}
PS. I set ASPNETCORE_ENVIRONMENT in my .pubxml deployment profile by adding:
<PropertyGroup>
<EnvironmentName>Staging</EnvironmentName>
</PropertyGroup>
For me it was because I had ASPNETCORE_ENVIRONMENT environment variable being defined 2 times in my app - one in web.config and another - in applicationhost.config
In my case just adding MVC into Startup.cs Please follow into image. I am trying to add dependency injection then showing this problem. I think it will be helpful.
Follow this Image: https://i.stack.imgur.com/ykw8P.png
Delete the 'hosting Model ="in process"' section in web config.
Example:
<aspNetCore processPath="dotnet" arguments=".\WebAPICore.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
to
<aspNetCore processPath="dotnet" arguments=".\WebAPICore.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
I'm also getting "HTTP Error 500.0 - ANCM In-Process Handler Load Failure"
Except in my case...Everything was running great until I got the Blue Screen of Death.
I have a solution with two startup projects. One is an API (that comes up) and the other is a WebApp(which gets the error). Both are .NET Core 3.1..also VS2019.
First I tried setting a break point in Main() of program.cs...it never got this far.
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
On a hunch...I Looked at the NuGet packages installed.
I uninstalled and (re)installed
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation(3.1.6)
...and now its working again.
In case anyone else cannot find a solution to this here was my scenario:
I recently started a new project using .NET 5, and everything was working. Then I upgraded from Preview 5 to 7 and all of a sudden my IIS Express would no longer work. The fix for me was to simply repair Visual Studio:
.
This happened to me when I switched form debugging in IIS Express to IIS. I inspected Event Viewer > Application log, and found the following error there:
Executable was not found at '...\bin\Debug\netcoreapp3.1\%LAUNCHER_PATH%.exe'
I then found the solution to that in the following thread.
I basically needed to replace web.config entry with hard-coded name of the application:
<aspNetCore processPath="dotnet" arguments=".\ProjectName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
I get that error when i try to get data from the ViewModel as List<> and my data is coming as IEnumerable format.
Before u guys update your vs2019 or delete some files,u should better to check it out that option.
For me it was caused by different web.config files for development and deployment :
development: <aspNetCore requestTimeout="23:00:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="false" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" startupTimeLimit="3600" hostingModel="InProcess">
deployment : <aspNetCore requestTimeout="23:00:00" processPath=".\Nop.Web.exe" arguments="" forwardWindowsAuthToken="false" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" startupTimeLimit="3600" hostingModel="InProcess">
In my case, I put app_name.exe back from my backup folder to bin\debug, and boom it worked.
If you don't have a backup folder that contains exe so don't worry publish your web app / web API and copy from there
No previous answers worked for me. In my case the "processPath" inside "aspNetCore" tag was pointing to a non-existing folder. A colleague told me that when any value in the web.config is wrong the app doesn't start and emerge this weird error.
In my case, after updating to .Net 6 and using a self contained application I started seeing this error.
I could manually set the module to AspNetCoreModule and the application would run in IIS but I knew this was just a work around since AspNetCoreModuleV2 should be used with .Net 6 applications
I had the following line in the ConfigureServices method:
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
Removing the compatibility version resolved my issue.
services.AddMvc();
This is a temporary problem caused by changes in folder or host settings while the application was running.
Most solutions provided here are working because they are indirectly triggering a restart. eg: Changing web.config will trigger a process cleanup and restart for that app.
Solution: Is restart the application process
If the problem still persist after the restart then check EventViewer to see the actual problem, a persistent problem usually means your application has a bug.
I tried changing aspnetCoreModuleV2 to aspnetCoreModuleV2, which worked, but it was a hassle to change every time I published it in Visual Studio.
After testing, I found that I could change the application pool default Settings for IIS to enable 32-bit applications in general.
But I haven't tested it on a 32-bit computer, it should be OK.
See Screenshot.
Fixing all project build errors, would simply fix this issue & the application will load.
Change platform target to Any CPU.

Deploying SP 2016 wsp to SP 2019 but resulting in error for Add-SP Solution

I have tried to Deploy SP 2016 wsp to SP 2019 but that resul in error for Add-SP Solution Input string was not in correct format at line 1.
I have opened the SP 2016 wsp in VS 2017 in an environment with the SP 2019 installed.
Also upgraded the solution when asked by VS 2017 to SP 2019.
It rebuild the wsp properly but not deploying.
Can anyone give me some idea on this?
Error which I am getting is:
Severity Code Description Project File Line Suppression State
Error CS0433 The type 'SPList' exists in both 'Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' and 'Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' Bamboo.FullTextSearch C:\Bamboo\LT200\SPX.HW11.ListSearch\dev\Bamboo.AdvanceSearchSolnDual\Bamboo.FullTextSearch\Bamboo.SimpleSearchEngine.cs 48 Active
There are lot of like this
1) Check references in your project: Microsoft.SharePoint.
2) If there is a reference and it's not corrupted, check the version by opening library properties.
2.1) If you have referenced a newer version, add an assembly binding with bindingRedirect in app config, for example:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.SharePoint" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="15.0.0.0" newVersion="16.0.0.0" />
</dependentAssembly>
</assemblyBinding>
3) Enable the Fusion log How to enable assembly bind failure logging (Fusion) in .NET and read the logs.

Web Package: How to force MSBuild to use MSDeploy.IisApp instead of sitemanifest?

How do I force MSBuild to create a Web Package that uses the iisApp Provider Application Path such as "Default Web Site/Catalog"?
My build process is creating a package that uses a directory path (C:\Agent\_work\28\s\Catalog).
I have tried to add the "/p:DeployAsIisApp=True" in my MSBuild command, but that doesn't seem to make a difference.
If I set the virtual directory to my Visual Studio 2017 solution folder, then Export a Package through IIS Manager, the package is created the way I'm expecting.
I compared the archive.xml files between MSBuild and the IIS Export. Here is some partial output:
MSBuild:
<sitemanifest MSDeploy.ObjectResolver.createApp= ...>
<iisApp path="C:\Agent\_work\28\s\Catalog ...>
...
</sitemanifest>
IIS Export:
<MSDeploy.IisApp MSDeploy.ObjectResolver.createApp= ...>
<iisApp path="Default Web Site/Catalog" ...>
...
</MSDeploy.IisApp />
So IIS is exporting MSDeploy.IisApp while MSBuild is creating a sitemanifest.
How do I get MSBuild to match the IIS Export? I'm using the VSTS build system and the parameters I'm passing to MSBuild are:
MSBuild /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:PackageLocation="$(build.artifactstagingdirectory)\Catalog" /p:IncludeSetAclProviderOnDestination=False
I solved the issue.
The specific issue I had been experiencing was a line in the logs that looked like this:
Verbose: Parameter entry 'IIS Web Application Name/1' could not be applied anywhere.
Parameters.xml was this (broken):
<parameters>
<parameter name="IIS Web Application Name"
description="Full site path where you want to install the Catalog Application (for example, Default Web Site/Catalog)."
defaultValue="Default Web Site/Catalog"
tags="IisApp">
<parameterEntry kind="ProviderPath" scope="iisApp" match="#defaultValue" />
</parameter>
I set the match attribute to an empty string. Then everything started working as expected. Working:
<parameters>
<parameter name="IIS Web Application Name"
description="Full site path where you want to install the Catalog Application (for example, Default Web Site/Catalog)."
defaultValue="Default Web Site/Catalog"
tags="IisApp">
<parameterEntry kind="ProviderPath" scope="iisApp" match="" />
</parameter>

BindingRedirect not being honored within cloud service

I'm receiving an exception when initializing a cloud service:
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Understanding that I have version 4.3.0.0 installed, I have added the following redirect into the app.config for my worker:
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
When run locally within the local emulator this resolves the issue. When this is packaged through cspack the app.config and worker.dll.config are included in the package.xml, both have the binding redirect included.
The 'Microsoft.WindowsAzure.Storage' is also included, both the .dll and .xml.
So as far as I see it, everything that is required during runtime has been supplied.
Unfortunately, the exception is telling me that the redirect has not been applied and it is still looking for version 2.1.0.0. Am I doing something wrong here?
Add a file named after your project so it'll match the name of the assembly.
{ProjectName}.dll.config with Copy to Output Directory = Always and Build action = None
This file has the same syntax as your app.config. It should contains your assembly bindings.
For some reason, the file generated from app.config is not included in the deployment package.

Error TF249051 using TFS 2008, VS 2012 and Windows 8

I have a Addin for Visual Studio, that connect to TFS 2008 server. I use VS 2012 in Windows 7 and Windows 8 (and 8.1).
No problem using my Addin, VS 2012 and Windows 7. All is OK.
But there is authentication issue using My Addin, VS 2012 and Windows 8.
Anyway, if I use Team Explorer and Source Control in VS 2012, there's no problem.
I get the following error:
TF249051: No URL can be found that corresponds to the following server
name: myTFS_server. Verify that the server name is correct.
Full trace:
Trace DomainName: myTFS_server
Trace DomainUri: http://myTFS_server:8080/
Trace ProjectName: MyTeamProject
Trace ProjectUri: vstfs:///Classification/TeamProject/5e1c44c0-a88c-4447-b2d3-1e9191abc700
Source Control: System.__ComObject
Error in Connect to TFS: Microsoft.TeamFoundation.TeamFoundationInvalidServerNameException: TF249051: No URL can be found that corresponds to the following server name: myTFS_server. Verify that the server name is correct.
at Microsoft.TeamFoundation.Client.TfsConnection.GetFullyQualifiedUriForName(String name, String locationServiceRelativePath, Func`2 getRegisteredUri)
at Microsoft.TeamFoundation.Client.TfsTeamProjectCollection.GetFullyQualifiedUriForName(String name)
at TeamExplorerManager.TFSServer.Connect(String serverName, ICredentialsProvider credentialsProvider)
TF249051: No URL can be found that corresponds to the following server name: myTFS_server. Verify that the server name is correct.. SourceControl: http://myTFS_server:8080/vstfs:///Classification/TeamProject/5e1c44c0-a88c-4447-b2d3-1e9191abc700.
Targets {http://schemas.microsoft.com/developer/msbuild/2003}Project
*** End OnStartupComplete ***
Any suggestions about it?
My Addin will have to make use of a bindingRedirect to redirect all versions to from v10 to v11.
For example:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.TeamFoundation"
publicKeyToken="xxxxxxxxxxxxx"
culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0"
newVersion="11.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.TeamFoundation.Client"
publicKeyToken="xxxxxxxxxxxxx"
culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0"
newVersion="11.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Make sure to update the publicKeyToken to the correct value.
Note:
Specific version does not work if the assembly is strong name signed.
Microsoft almost certainly strong-name signed their assembly.
References:
SpecificVersion=False with TFS API dll's

Resources