Cannot deploy Razor web-site to IIS, HTTP Error 500.19 - Internal Server Error - asp.net-core

I am a beginner with IIS and razor pages. Currently, I am trying to deploy an internal web-site built using net core written using razor pages, but it keeps giving a server HTTP Error 500.19 - Internal Server Error.
This is an internal web-site so not open to world. I looked at this thread and installed the components they mentioned by did not help.
How do I resolve "HTTP Error 500.19 - Internal Server Error" on IIS7.0
As a test this is just the webapplication1 template code that is created with the wizard. So I have this on launchsettings.jon. Noted that I added the https://myinternalsite.net/ which is the URL mapped. Not sure if this is necessary.
Properties\launchSettings.json
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WebApplication1": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000;https://myinternalsite.net/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
I tired to deploy using "Folder", currently the url is mapped to the server #:
C:\inetpub\wwwroot\
However I am publishing the site directly inside the server with "Publish" to folder as below:
Here are the IIS packages installed:
But one thing that bugs me is that when I deploy to the local folder I see this:
C:\inetpub\wwwroot\wwwroot
two nested wwwroot folders! Not sure if this is the problem.
but this what I get, when trying to deploy there:
but If I try to deploy to C:\inetpub, I get different errors like this:

I found out the issue, but not sure why it happened. To get it work, from my local machine I did "publish to folder" as above. My machine has all the .net core 3.1 installed. Then I copied my entire local binary folder to the remote server. Then I changed the IIS to point to this folder and it worked.
For whatever reason that I don't understand, building the web-project inside the sever did not work, but if I do it locally and copy the all the binaries there it worked.
VS2019 installed onto the server must be missing something, which I have not idea what it is.
thanks for all the tips in all cases.

Related

deploy blazor server to LAN

I created a game, and I'm trying to play it with my friends. Since we don't want to pay any ASP.NET Core server space on Azure or whatsoever, we are running the game ourselves and trying to join using a VPN.
I created a Blazor app with an ASP.NET Core server. I modified the launchSettings.json like this:
"profiles": {
"VikingBoardGames.Server": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7141;http://localhost:5141;https://*:7141" <--- THIS !!
},
[...]
}
Now, from my local computer where I have visual studio, I can access it via http:localhost:5141 AND http://MYIP:7141. which is good.
Then I created a VPN using hamachi. My friend joins the net. He can ping my hamachi IP.
I start the game on visual studio, and visit my IP to see it
He can visit my VPN IP on port 7141, where the page header gets loaded. Thethe "loading..." message appears, but it freezes.
Upon checking the developer tools on chrome on my friends' computer, I see:
DevTools failed to load source map: could not load content for chrome-extensions://gighmmpiobklfepjocnamgkkbiglidomm/browser-polufill.js.map: System error : net::ERR_FILE_NOT_FOUND
And at this point, I don't know how to proceed.
I don't need debugging facilities on his computer, just to be able to join the game and have fun.
What can we do?

IHostedService not running on IIS 10

I have a ASP.NET Web-API which has a IHostedService to periodically execute a specific Task (fetch data from another website and write it to the Database).
This works well on IIS-Express (starting from inside VisualStudio)
But when publishing the API to either my local IIS or the IIS of my external provider, the IHostedService doesn't start.
in my startup.cs:
services.AddHostedService<QuartzHostedService>();
I tried adding values to the Database manually when calling a specific Path, so that's not the problem. It has something to do with IIS i guess. Problem is, I don't have access to the external providers IIS configuration. Everything i found online showed some IIS configuration.. I hope someone can help.
Steps to setup on IIS
Adding "Application Initialization" feature, only available since IIS 8.0 and hier.
First do you need to enable on server the feature "Application Initialization", so, on "Server Management" --> "Management" --> "Add roles" --> "IIS Web Server" --> "web Server" --> "Application Development" --> "Application Initialization"
Create your Application Pool
Set properties:
starter mode: AlwaysRunning
.NET CLR: V4.0 (even if your project is .net core,beacuase the configuration donesn't work fine if you change that)
Idle: 0
Create your Application under your IIS Site and configure advanced settings:
ApplicationPool: with the pool created on previous step
Preload active: True
Start yoour Pool or recycle and your hosted service must run,
IMPORTANT:
Exists an issue,
https://learn.microsoft.com/en-US/troubleshoot/developer/webapps/aspnet/site-behavior-performance/application-fail-ssl-web
So if your site has enabled "SSL Required" do you need to change that from your particular site,
On iis select your application and on Middle planel "IIS" section double click on "SSL Configuration"
Then uncheck "SSL Required"
Your Hosted Service

Publish .Net Core app with Entity Framework to IIS

I am trying to published my .Net Core app to IIS that uses Entity Framework. I can publish it fine but no database is included in the publish wizard.
I have followed different tutorials including this:
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.0
However none tell you how to deploy your database or what needs to be done if using entity framework. I'm relatively new to published and hosting web apps so I'm not sure what to do.
At the moment my frontend of the web app loads on IIS but when I go to login it brings up a 500 error. I have included my connection string and added a user and gve correct permissions under SSMS.
It came to my attention when publishing it shows "no databases found int he project".
Would this effect me not being able to access the database and bringing up the 500 error when logging in and how do i fix this.
No databases found in the project
How did you created your database locally in the first place? Did you manually ran the database update command? I would suggest you add to your startup.cs file a code to ensure your database is created and any missing migrations were applied, you can achieve this within your Configure method:
using (var scope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())
{
scope.ServiceProvider.GetRequiredService<DbContext>().Database.Migrate();
}
Or just EnsureCreated() instead of Migrate() if you don't to apply missing migrations on future loads.
It seems that you need to change your ConnectionString configuration in appsettings.json from the format
"Data": {
"DefaultConnection": {
"ConnectionString": "xxxxxx"
}
}
to:
"ConnectionStrings": {
"DefaultConnection": "xxxxxx"
}
And your startup with
services.AddDbContext<ApplicationDbContext>(opt => opt.UseSqlServer(Configuration["ConnectionStrings:DefaultConnection"]));

How to deploy Strapi to an Apache cPanel

I'm setting up a Strapi install in my Apache cPanel (WHM on CentOS 7), and can't find a proper way to deploy it. I've managed to get it running, but when I try to access the dashboard (/admin), it just shows the index page (the one in public/index).
Is this the proper way to deploy Strapi to an Apache server?
Is the "--quickstart" setting only for testing purposes, or can this be used in Production? If so, what are the pre-deployment steps I need to take?
This is for a simple project that requires easy to edit content that will be grabbed via API manually from another cPanel installation.
Reading through the Strapi docs, I could only find deployment information about Heroku, Netlify and other third-party services such as these, nothing on hosting it yourself on Apache/cPanel.
I've tried setting up a "--quickstart" project locally, getting it working and then deploying via Bitbucket Pipelines. After that, just going into the cPanel terminal and starting it - though the aforementioned problem occurs, can't access admin dashboard.
Here's my server.json configuration:
Production
{
"host": "api.example.com",
"port": 1337,
"production": true,
"proxy": {
"enabled": false
},
"cron": {
"enabled": false
},
"admin": {
"autoOpen": false
}
}
Development
{
"host": "localhost",
"port": 1337,
"proxy": {
"enabled": false
},
"cron": {
"enabled": false
},
"admin": {
"autoOpen": false
}
}
There are no console errors, nor 404s when trying to access it.
Edit
Regarding deployment with the --quickstart setting:
there are many features (mainly related to searching) that don't work properly with SQLite (lack of proper index support) Not to mention the possible slowness due to disk speed and raw IOPS of the disk.
A suggestion on how to implement:
Respectfully, to deploy strapi you likely need to:
1. build a docker container for it
2. make a script to deploy it
3. use SSH and do it manually
4. use a CI/CD platform and scripted to deploy it
In summary:
Strapi is not your typical "copy the files and start apache" it's not a flat file system, Strapi itself is designed to be run as a service similar to Apache/Nginx/MySQL ect. They are all services (Strapi does need Apache/Nginx/Traefik to do ssl for it though via proxying)
If you have the index page when you visit /admin it's because the admin is not built.
Please run yarn build before starting your application.

Reference a local WSDL in a .NET Core SOAP service

I have a SOAP service defined by a local .wsdl file that I want to use to generate a .NET Core Connected Service in Visual Studio 2017.
My ConnectedService.json looks something like this:
{
"ProviderId": "Microsoft.VisualStudio.ConnectedService.Wcf",
"Version": "15.0.20119.1312",
"ExtendedData": {
"Uri": "C:\\Path\\MyUsername\\LocalRepository\\soap-service.wsdl",
...
},
...
}
The problem is that this completely breaks for anyone else who accesses this source and doesn't put their local repository in the exact same location as I do.
I want the reference to be relative to the project, like "Uri": "soap-service.wsdl", but that results in an error:
How can I configure ConnectedService.json so that it finds the local file relative to the .NET project?