Deploying .Net Core WebAPI project on IIS - asp.net-core-mvc

I have created a simple web API using .Net Core and trying to publish it to IIS. But getting HTTP 500.
I followed https://docs.asp.net/en/latest/publishing/iis.html article and did exactly whatever mentioned in that.
I Installed only https://www.microsoft.com/net/download as
DotNetCore.1.0.1-WindowsHosting.exe OPT_INSTALL_REDIST=0
NOTE : I am able to deploy and access MVC application successfully but cannot access WebAPI application with the same steps.
In the IIS logs i am seeing below error.
Failed to start process with commandline '"dotnet" .\Project-1.dll', ErrorCode = '0x80070002'.
I am using the default web api template provided in Visual Studio 2015
am i missing something. Is WebAPI deployment is different to MVC app deployment w.r.t .net core ?

When you install the .NET Core Windows Server Hosting bundle, it won't restart all of the IIS processes if IIS is currently running. This is a good thing, since on a production server you wouldn't want them just to restart, but it would be nice if it was made a little clearer. First, check your System (not User) PATH variable to ensure that the path to Dotnet is there. Then, go into services and restart the Windows Process Activation Service. This will restart all of the IIS bits and get it to update the path. Once you've done this, IIS should serve up your .NET Core app just fine.

Related

Is it possible to debug a .NET application that is deployed to IIS on my local machine?

I have incorporated Azure authentication in to a .NET application on my local development machine. When I debug/run the application in Visual Studio the app runs just fine.
I have deployed the application to IIS on my local development machine and have configured a new site binding of type HTTPS which uses an SSL certificate that I have created locally and added to my "Trusted Root Certification Authorities" store. When I try to browse the application through IIS, I get a generic error message that is generated by the Application_Error method in my global.asax.cs file.
Is it possible for me to use a debugger to "step through" code that has been actually deployed in IIS? I think that I have found MSDN documentation that describes doing this for a .NET Core application (https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/development-time-iis-support?view=aspnetcore-2.1) but I my app is written in .NET 4.8 so I don't think it applies for me.
To debug an ASP.NET application that has been deployed to IIS, install and run the remote tools on the computer where you deployed your app, and then attach to your running app from Visual Studio.
For more information about "Remote Debug ASP.NET on a Remote IIS Computer", you can refer to this link.

ASP.NET Core launch settings: IIS Express, IIS, Project, Executable

My Google skills are lacking at the moment. When should I be using IIS Express vs. IIS vs. Project vs. Executable? What are the pros/cons of each?
IIS Express: A common default that runs the ASP.NET Core application behind the IIS Express development server. This is a good default.
IIS: When you actually have a full IIS installed, you can set this up, so that your application runs directly behind IIS. That isn’t really a good choice for development, at least not for ASP.NET Core, and I actually don’t even know if this works properly with ASP.NET Core.
Project: This runs the application as a console application. As a result, this is the same as running dotnet run from the command line. This is also a very good option for debugging, as you can directly see the logging output. Depending on your target production environment, this might even make more sense than running behind IIS Express.
Executable: This allows you to run an arbitrary executable. That’s not really useful for running your ASP.NET Core project.
So basically it comes down to IIS Express or Project. These are the two that are also configured properly by default in the launchSettings.json file that comes with the ASP.NET Core application template.
Whether you prefer IIS Express or running the application directly probably comes down to personal preference. So just give both a try and see what feels nicer to you.

Visual Studio OWIN Self-hosted App deployment

I've got an OWIN Self-Hosted SignalR app. I'm looking for a way to automatically deploy it to a different server (one is local, one is in Azure cloud) from Visual Studio. I'm not using IIS, I want to run it either as a normal app or as a Windows service.
What are my options?
I advise you to consider using TopShelf
and here is the Nuget Package
All you need is to build and deploy the bin folder then just run one command

Where is Web Deploy's httpHandler configured?

I verified that I have installed Web Deploy 3.5 and I can see the Web Management Service running in services.
When I attempt to deploy to this service with VS 2010 or msdeploy.exe on the command-line, even locally, to https://servername.com:8172/Msdeploy.axd?site=mySite, I get a 404 returned from IIS.
It is my suspicion that I should see the httpHandler among those listed in the .NET 4.0 Web.config, but I do not.
The web deployment handler is installed by Web Deploy which needs to be installed onto the server. You can find the installer at http://www.iis.net/downloads/microsoft/web-deploy with a couple of installer options available. Make sure you include the "IIS 7 Deployment Handler" when you install it. From there you'll probably want to take a look at this article which explains how to get the correct permissions to the correct user accounts.
There's nothing in your project web.config that would be required to make it work. That's why the deployment handler is available on a separate port (8172).

What's the easiest way to deploy an ASP.NET MVC 3 project to Windows Server 2003?

Is there some kind of deployment wizard I can run and have it install just the things it needs to run right onto the server end point? Do I have to build the project using VS2010 on the server? If I can't get this thing deployed today I am really going to be screwed.
IIS 6 is there and I think .NET 4 is installed (I tried installing it from Microsoft and they had me install a million things like VS2010 express and SQL Server and all this other crap, the install failed but .NET 4 does show up in IIS).
I achieved this by enabling an FTP site for the IIS server website and using this to deploy the web application within visual studio 2010 which will build and deploy just the changed files for each build. Works very well. You can even add a Publish toolbar to help deploy regularly more easily.
All you have to do is install the .NET Framework 4.0 (32 / 64 depending on build) and run aspnet_regiis.exe in the Framework folder.
For me this is located here:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe
Hope this helps!
You can also use the publish command from VS 2010 to save it to the filesystem and then copy the files into an IIS site on the target server. Just map a network drive to X: or something (for your sites root) and publish directly to the share.
You can take a look at Web Deployment projects or even the VS "Publish" feature
From the Build menu in VS2010, just click Publish [name of your web project] and enter the location on your web server where the site is going to be hosted.
VS2010 will publish the files required there.
It shouldn't be necessary to install VS2010 Express, just to deploy a site. But if .Net 4 and ASP.NET MVC 3 is installed, you should be able to deploy. Right click the web app in VS2010, and hit Publish.
Remember to set the configuration to Release!
But, with IIS 6 you could be in for a fight in regard to HTTP Modules, Handlers and other server configuration. Anything inside your Web.config's system.webServer section will always be ignored by IIS 6.

Resources