Web API 2 get up and running on local IIS - c#

I have Web API 2 C# project which runs fine through visual studio. I type URL to test like this:
http://localhost:51754/api/email/1
It shows me XML file. However when I publish and set up IIS I get
HTTP Error 403.14 - Forbidden.
I am new to this and my question is what kind of configuration I need to have it run on IIS. I am using .NET Framework Version 4.0 Integrated Application Pool to run it.

Probably ASP.NET is not registered within your IIS. Try running the following command from a DOS prompt with elevated user account:
C:\windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir
Obviously you might need to adapt the path to aspnet_regiis.exe depending on your specific OS and version of the framework. Once you have registered ASP.NET 4.0 with IIS make sure that you restart it for changes to take effect:
iisreset

Related

Server Error 403 Forbidden on Blazor server app published to Linux hosting

I want to deploy a Hello World Blazor Server App created with the Blazor App Source Template 3.1.11 in VS2019 C#
The app is created in VS2019 on Windows 10
The docs show how to create the /bin/Release/{TARGET FRAMEWORK}/publish folder
I copied the files here to the domain folder in my hosting package, but do not know the next step.
web.config is for windows hosting.
What do I need to do for Linux?
At the moment I get a 403 error if I go to the site.
I can publish the app to a windows hosted site.
[Update]
It turns out that the Linux server does not have DotNet installed.
By default, dotnet publish publishes the entire application for running on the current operating system. When that does not match where you intend to run the application you can specify the runtime to publish for with -r|--runtime.
Something like this should work: dotnet publish -r linux-x64
A 403 error would lie somewhere in the IIS/web server configuration. Look at the config file or the IIS settings.

MVC 5.0 500 - Internal server error

I have created an MVC 5 website using Visual Studio 2015 on a Windows Server 2016 Machine.
I build and run the application from VS and it works great.
I published it locally, pointed IIS to the root folder.
The Application Pool is set to .Net CLR Version v4.0.30319.
When I try to access the page on the web, I get a generic error
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
There is nothing in the IIS logs.
Not sure how to get this error so I can see it...or if it is a more basic issue. Any ideas on the best way to proceed?
To configure within Microsoft Server 2016, do the following:
Make sure you've installed the feature set for Web Server & Hosting are installed.
If those are installed, create a directory such as: "C:\Program Files\Sample"
Publish your application to the directory
Open Internet Information System
Disable Default Site
Create a New Site
Create a Site Name "Sample" (Take note of the Application Pool Name)
Now link "C:\Program Files\Sample" in Physical Path
For now leave the binding defaulted, this will trigger wildcard
Uncheck Start Website Immediately
Navigate back to "C:\Program Files\Sample" (Accessible through IIS also)
Right-Click and go to Permissions
Choose add new user
Type in "IIS AppPool\Sample"
Choose access your application will require.
Apply those changes, then navigate and start your web-site.
If that doesn't work, you can check the following:
Application Pool:
Sample should of defaulted to integrated and 4.0, if not change it. If your utilizing .Net Core application, you want it to be Unmanaged Code
Programs and Features:
Make sure that you have .Net 3.5, 3.0, 2.0 enabled.
Hostable Web Core & Internet Information System (Under Web Server) for you.
World Wide Web Services Enabled, with the proper Application Development Features.
Dependencies:
You may have to install https://www.microsoft.com/download/details.aspx?id=53840
If you have Core, you'll need: https://aka.ms/dotnetcore-2-windowshosting

.NET Core app runs locally on web server, but not accessible via remote browser

I have an ASP.NET Core 1.1 web app which I've published to a remote server.
I've set the website up in IIS following these instructions. I know the bindings and firewall etc are configured right because before I installed the .NET Core app I could browse to the binding URL and see the IIS default page.
After adding the .NET Core application to the website directory, browsing to the same URL just returns a HTTP Error 502.5 - Process Failure error. However, if I run the application in a command prompt locally on the server (running dotnet .\MyProject.dll) it reports that the application started OK. At this point I can browse to the site locally on http://localhost:5000 and it works correctly.
So I assume this is an issue with my IIS setup. What might I have missed? I've installed the ASP.NET Core 1.1.1 Hosting Package. The application pool user has modify permission on my application directory and read permission on C:\program files\dotnet. The app pool is configured for no managed code. Clearly the runtime is correctly installed or it wouldn't work locally. Unfortunately the server's event viewer is not very helpful, just gives me:
Application 'MACHINE/WEBROOT/APPHOST/MYPROJECT' with physical root
'C:\Sites\MyProject\' failed to start process with commandline 'dotnet
.\MyProject.dll', ErrorCode = '0x80070002 : 0
Any assistance would be very appreciated.
UPDATE 1
I hadn't long posted this when I found this on SO. One of the unaccepted answers suggested changing "dotnet" to "C:\Program Files\dotnet\dotnet.exe" in the web.config to end up with this:
<aspNetCore processPath="C:\Program Files\dotnet\dotnet.exe" arguments=".\Picsolve.Web.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
This fixed the problem! Can anyone explain why this ight have been? I've checked my system environment variables and can see C:\Program Files\dotnet in there.

Unable to run ASP.NET Core rc2 in IIS

So, I've been trying to publish my Core App to local IIS server but whatever I do it just doesn't want to run.
What I do is find the project in windows explorer and open a command window there, and write the following:
dotnet publish --framework netcoreapp1.0 --output "C:/ReleaseWebsite" --configuration Release
Which well executes without any errors, and finally says that it published the project correctly.
After that I go to IIS and Add New Website, set it to port 80 or 8080, I even tried with 8088, and after set the path to the published files, I edit the Application Pool and set it to No Managed Code. Start the website but all I get it 500 error An error occurred while starting the application.
If I go manually to the published files and open GST.Web.exe it starts without any issues, and rusn on port 5000 and I can access it without any problems. But I want to run it in IIS. Any help?
Refer Publishing to IIS article.
I think you must have done all the steps from this article except installing .NET Core Windows Server Hosting bundle on the server.
Install the .NET Core Windows Server Hosting bundle on the server.
This bundle will install the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module. The module creates the reverse-proxy between IIS and the Kestrel server.
See if this helps.

Running ASP.NET MVC 6 Web API from IIS

I create a MVC 6 Web API project that is running as expected from Visual Studio, when I'm however deploying to production I'm getting a
An error occured while starting the application
error.
I did the following on the production machine
Installed ASP.NET 5 from https://get.asp.net
Made sure that the production environment is running the same dnx version
that the application was published with
Installed HttpPlatformHandler 1.2
Set the application pool .NET CLR Version to No Managed Code
Pointed the root location to the wwwroot folder
Is there anything else that I'm missing?
When you run into 500 errors, remember that ASP.NET 5 application can be self hosted,
Open a command prompt
Browse to the application directory
Type in web.cmd
I had some reference problems within my application that was listed in my command prompt which I subsequently fixed and everything worked as expected.
500 can be thrown by different failures. Take a look on http://docs.asp.net/en/latest/publishing/iis.html what u've missed in your configuration.
And you should call it ASP.NET Core 1

Categories