Cannot run published website that using database - asp.net-core

I started to code my new website using ASP.net core
Everything runs properly with development environment: Open VSCode and F5 to run.
But after i publish all of them to IIS, it runs with 404 error
This localhost page can’t be found No webpage was found for the web
address: https://localhost:1111/ HTTP ERROR 404
The error page is displayed when the page connects database to runs backend actions.
Any actions in published web that don't use database such as href to another link, run javascript validation, ... would run with no 404 error
Do I miss anything or make something wrong?
here're the steps that i did to publish my site
open terminal and run dotnet publish --configuration Release
copy publish folder in bin\Release\netcoreapp2.2\publish to the publish folder in IIS setting
open IIS and add application pool with .net CLR version is No managed code
add website with application pool above, bind type is https, hostname is localhost, and tick all 3 checkboxes (Require server name indication, Disable HTTP/2, disable OCSP Stapling), SSL certificate is IIS Express Development Certificate
I forgot the page that guided me those steps

I myself have found the cause. The reason that the web app return a 404 page when I post something to backend to process database is I used windows authentication in my database connection string. So it couldn't access the database when I publish to IIS. When i change connection using sql server authentication, it works properly

Related

Publish .NET Code application to Arvixe Host

I have a ASP.NET Core with Blazor website and I want to deploy it to Arvixe host. The website is very simple and contains only UI elements no database required. I published the website to a local file system and uploaded it using FTP to the Plesk.
When I am visiting the website, I receive this error:
500 - Internal server error. There is a problem with the resource you
are looking for, and it cannot be displayed.
I have tried to run it on the IIS and I received more details:
Configuration The configuration file cannot be read due to
insufficient permissions.
I tried to add IIS_IUSRS to the group and users for web.config but I am not able to find it because I am using a windows 10 connected to active directory.
Besides, I still don't know how to solve this problem at Arvixe. Does anyone know tips might help?
500 internal error is generic issue. Please kindly check the error message on the server and paste it here. Make sure that your provider has installed .net core bundled on their server and here are tutorial about publsih .net core using plesk https://windowswebhostingreview.com/how-to-publish-using-web-deploy-with-plesk-control-panel/. It should be working fine.
You need to give Full Trust permission (Read-Write-Execute) to your application folder and also to Application Pool and also check if the Runtime version supported by Arvixe matches with your Asp.net Core version.
Also enable the logs in web.config file by setting stdoutLogEnabled="true" to get detailed error so that you can investigate more about the error.

ASP.NET Core web app response with 502 error

I'm investigating an issue with the asp.net core 1.1 web app.
We had to install the latest VS 2017 on the build server. And straight after that, all the deployed builds return 502 responses. Nothing changed in the app code or the referenced packages, however, many binaries are different after VS 2017 install. The deployment is done via FTP.
I also noticed there is now a small difference in Http response headers. API Response Headers used to have Server: Kestrel. But now, after installing VS2017, the deployed builds return Server: Microsoft-IIS/10.0. This probably explains 502 error, but why would the Server now switch to IIS?
Managed to fix it. The error is caused because IIS server (proxy) can't access AspNetCoreModule, the process that hosts kestrel. Usually, the reason is because kestrel in some trouble.
The solution starts with checking Application logs in Event Viewer on the server.
In my case it was:
Application 'MACHINE/WEBROOT/APPHOST/MyApp.API' with physical root '\servername\c$\inetpub\wwwroot\MyApp.Api\' failed to start process with commandline '"dotnet" .\MyApp.Api.Web.dll', ErrorCode = '0x80004005 : 80008083.
So, by googling the error code I've realised that the server didn't have the right asp.net core version (for some reason).
Downloaded the installer, works fine now! :)

iis express - cant get ssl to work in visual studio 2015

Im trying to get my website to run under https but for some reason IIS express wont play ball. I have SSL enabled set to true, anonymous authentication is disabled and ive pasted the https url into the project url section. Whenever I start the app it runs under standard http. Is there something im missing in the setings ?
Please see if this helps: http://codehotfix.com/enabling-ssl-with-iis-express-in-visual-studio-express-for-web/
Select the startup project and press F4 (the function key) this will open the property window.
To enable the SSL with in IIS Express, you have to just set “SSL Enabled = true” in the project properties.
Once you change the value, Visual Studio set in automatic the SSL URL, e.g., https://localhost:44301/
Copy SSL URL. Go to the Advance properties by pressing Alt+Enter, select the Web tab and set the Project URL with the same value of SSL URL, e.g., https://localhost:44301/
Now you have configured the default URL of the web application, we can run the site (F5 or CTRL + F5).PS: The first time you set the secure protocol on IIS Express, you will be prompted to install the certificate for SSL.
My guess is that you need to change the Start URL in the Project settings (under the Web tab).
The article you followed assumes that it's not set to anything, but you may have set it previously, and it just needs updating to the https:// based URL.

GeoDesic Buffers sample code does not work in my local IIS Server

I am new to use ArcGis Api for javascript, I am using JS Api 3.20.
I have been trying for 3 days but it does not work.
I have taken code from the following link
Geometry Engine - Geodesic buffers | ArcGIS API for JavaScript 3.20
I paste this in My Html file create in VS website for .Net , and setup a local server for my page using IIS server
I also downloaded proxy from GitHub resource-proxy/DotNet at master · Esri/resource-proxy · GitHub
setup it in same application in IIS
Downloaded excel file added in my application from https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.csv
but still I am getting the following error in console using developer mode when set Proxy URL to this
config.defaults.io.proxyUrl = "/192.168.8.188/Proxy/proxy.ashx";
GET http://192.168.8.188:1555/192.168.8.188/Proxy/proxy.ashx?http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.csv 404 (Not Found)
and when I set proxy url to this
config.defaults.io.proxyUrl = "/Proxy/";
then the following error occurs in console
GET http://192.168.8.188:1555/Proxy/?http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.csv 403 (Forbidden)
Could you please help me out. I would be thankful in advance.
I Resolved My Issue thanks.
Basically I didn't enable IIS 4.5 web features so I read readme file of proxy which resolved my issue.
Here is what I read from ReadMe file located in DotNet folder of Proxy
Troubleshooting: If you get an error message 404.3, it's possible that ASP.NET have not been set up. On Windows 8, go to "Turn Windows features on or off" -> "Internet Information Services" -> "World Wide Web Services" -> "Application Development Features" -> "ASP.NET 4.5".
First off, try setting the proxyUrl value to this:
config.defaults.io.proxyUrl = "/proxy/proxy.ashx";
That may resolve the issue.
EDIT (based on clarification that IIS is in fact running on port 1555):
You might want to confirm that you can access the proxy at all, by entering the proxy url directly in your browser (with no arguments), eg:
http://192.168.8.188:1555/Proxy/proxy.ashx
If this resolves correctly, you should get an error response in JSON format like this:
{error: {code: 400,message:"This proxy does not support empty
parameters."}}
That at least would confirm that the proxy is accessible and functioning properly on your system.

How to define launchUrl in IIS Express config file

I have created a basic .NET Core 3 API app with the default settings. It has only one controller called "WeatherForecastController". In the "launchSettings.json", the launchUrl setting was set to "weatherforecast" under "IIS Express" profile. By clicking on the run button in Visual Studio, I can easily run the project.
But I wanted to run the app via IIS commandline, so what I did was running the below in cmd.exe
iisexpress.exe /config:C:\Users\User\source\repos\SingleExecWebApp\.vs\SingleExecWebApp\config\applicationhost.config /site:SingleExecWebApp
The app runs, and I got the following error
HTTP Error 500.0 - ANCM In-Process Handler Load Failure
The IIS console emits the following info
Starting IIS Express ...
Successfully registered URL "http://localhost:61517/" for site "SingleExecWebApp" application "/"
Successfully registered URL "https://localhost:44325/" for site "SingleExecWebApp" application "/"
Registration completed for site "SingleExecWebApp"
IIS Express is running.
Enter 'Q' to stop IIS Express
I think what I am missing is the previously mentioned "launchUrl". Am I correct? if yes, how to set it in the above command I ran in cmd.exe. If no, what I am I missing?