Publish and Deploy .NET Core SignalR on IIS - asp.net-core-mvc

I have a working .NET Core SignalR project locally.
I published the project to a local folder.
I then copied the files to an IIS server.
I get a HTTP Error 401.3 - Unauthorized Error when browsing the service.
I checked the ACL of the folder which contains the library and have given
full access to IIS_USR
The web.config file is somewhat empty
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
Any ideas?

Related

How to deploy a FastAPI web app on IIS server?

I have a FastAPI web app that I'm trying to deploy on IIS version 10.0.* on Windows server 2019.
Right now, I can run the application locally with no issues, you can find the repository here:
https://github.com/shaybarak11/Twitter-API
What I'm doing in order to run it locally is running the application via the CMD:
python main.py
And in the main.py file, I have this line of code that start the app:
uvicorn.run("main:app", host="0.0.0.0", port=8000, log_level="info")
So now, I'm trying to deploy this app on IIS.
These are the steps I took so far:
downloaded IIS on the Windows server.
hit add website on IIS Manager page.
added the Physical path of the project directory.
connected as the Administrator.
Went to Handler Mappings and added the python interpreter.
Following the guide of configuring the web.config file for python app,
I get now HTTP error 500.19 - that indicates the problem is with my web.config file.
My web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="C:\Users\Administrator\AppData\Local\Programs\Python\Python39\python.exe"
arguments="C:\Users\Administrator\Desktop\Twitter-API\main.py"
stdoutLogEnabled="true"
stdoutLogFile="c:\home\LogFiles\python.log"
startupTimeLimit="60"
processesPerApplication="16">
<environmentVariables>
<environmentVariable name="USERNAME" value="root" />
<environmentVariable name="PASSWORD" value="password" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
Does someone have any idea what the error is?
Many thanks,
Shay.

Autogenerated web.config not accepted by IIS 10

I want to publish a entity framework core (.Net) to a IIS.
For this I publish the application in Visual Studio Community 2017. When I publish the application the web.config file will be auto generated as the following
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\basket.api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: ba174064-1719-4e47-a0c3-5e8cff312047-->
I go to my IIS 10
I post it into the default website. Into to the location "C:\inetpub\wwwroot".
I start the web site an access via the webbrowser localhost.
I get allways the following error message:
I check the web page of Microsoft of the error code 0x8007000d,it is basicly saying that the format of a XML Element is not correct. Which is impossible I check all the formating and also I let autogenerate by the Visual Studio when i publish the site. I tried everything and don't know what to do. I am very newbie in IIS stuff.

Configuration of ASP.Net Core

I have a web project that the front-end is Angular 5 and the back-end is ASP.NET Core. the front-end and back-end are in separated projects.
I have a host with Windows as OS and Plesk as control panel, the Document root folder is home and placed in Home directory
I publish my api to home/api directory but I get some errors about not started application(502), when I publish my api to home directory, I can not access my front-end files and I get page can’t be found error
here is my web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
Is there any way to publish the API on any folder? like home/api

Unable to set $(ReplacableToken...) in Web.config when publishing a Web Project

I have a web project and I craeted a Test publish configuration. I use Web Deploy Package for publish method. My target is to have a replacable parameter for a setting in appSettings, so that on deployment a new setting value would be used in SetParameters.xml. I use parameters.xml file created in the root project folder with the following structure.
parameters.config
<parameters>
<parameter name="webApiUrl"
defaultValue="http://localhost:50594/">
<parameterEntry
kind="XmlFile"
scope="Web.config"
match="/configuration/appSettings/add[#key='webApiUrl']/#value" />
</parameter>
</parameters>
Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="webApiUrl" value="http://localhost:50594/" />
</appSettings>
</configuration>
The problem is that when the project is published the webApiUrl setting is not changed to $(ReplacableToken_webApiUrl) so when the project is deployed the value in SetParameters.xml is not taken into consideration.
I used a lot of different variations of scope and match, but non of them worked.
scope="\Web.config$", "obj\x86\Test\Package\PackageTmp\Web.config$", "\Web.config$", "\web.config$"
When I publish the project I check the folder (ProjectRoot)\obj\x86\Test\Package\PackageTmp\Web.config to see if the parametrization works.

How do you add a mime type when using ASP.NET vNext?

There's LOADS of information on how to add MIME types into a normal project.
These include configuring IIS, or modifying the web.config.
Both of these options are unavailable to me in vNext with IIS Express.
I had a look at the schema to the project.json file and couldn't find anything in there that would help either.
Can this be done yet? - I want to add a mime type for the .woff2 extension.
If you hosting it on IIS 7 or later then following step will do what you need. This answer I have used Visual Studio 2015 CTP5.
Publish your web application ( ASP.net vnext)
You can publish it to location like C:\MyPublish
Once it get successfully published you will find following location C:\MyPublish\wwwroot. Here You will find web.config.
Now host your site to in IIS ( Make sure that you have used C:\MyPublish\wwwroot as your path)
Now edit web.config over here just like you did for old version to add mime type. ( Following is my edit)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="kpm-package-path" value="..\approot\packages" />
<add key="bootstrapper-version" value="1.0.0-beta2" />
<add key="kre-package-path" value="..\approot\packages" />
<add key="kre-version" value="1.0.0-beta2" />
<add key="kre-clr" value="CLR" />
<add key="kre-app-base" value="..\approot\src\WebApplication5" />
</appSettings>
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
</system.webServer>
</configuration>
Note: As per my thinking In old version it is fix that it is always windows environment so we have direct web.config file in project and we edit that but now we have to follow different process to register as in future we can host completly on linux env as well.
Update : There is another way to do that as well. If you are using Microsoft.AspNet.StaticFiles package then you will have extension.
public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles();
}
This will indirectly use https://github.com/aspnet/StaticFiles/blob/dev/src/Microsoft.AspNet.StaticFiles/FileExtensionContentTypeProvider.cs. Here you can see all mapping.
Update 2: (Add New Mime Type)
public void Configure(IApplicationBuilder app)
{
StaticFileOptions option = new StaticFileOptions();
FileExtensionContentTypeProvider contentTypeProvider = (FileExtensionContentTypeProvider)option.ContentTypeProvider;
contentTypeProvider.Mappings.Add("<<yourextention>>","<<mimetype>>");
app.UseStaticFiles(option);
}
Until this is released, you can also edit applicationhost.config which I found in D:\Documents\IISExpress\config (yours might be on your C drive [Documents]).
I added:
<mimeMap fileExtension=".woff2" mimeType="font/x-woff2" />
Inside <staticContent>.

Resources