ASP.NET Core 2 Web API, Azure publish issue - asp.net

I have created a sample Web API that returns some sample data from an SQLite database which is included in the project.
I am able to browse and run the API on my local computer. This is all good.
I am also able to publish that API on Azure, all files are getting deployed I am getting "Publish successful" message as expected.
After, whenever I try to browse the azurewebsites.net domain, it doesn't browse it at all.
Once I create empty web site/web app, I am able to browse the welcome page on azurewebsites.net. But once I publish the API, I am getting 404 not found error, 503 error or IIS 502.5 error.
I tried to change settings from Azure portal, all settings seems good, .NET framework version is set to 4.7, as well as my project is too. Anyone has any idea?
I found the problem
I was using SQLite DB, and my SQLite database was open in a database editor. So, Even though Visual Studio published the database, the database file was 0 byte since it was in use and locked.
I think this is short of a bug. If Visual Studio says I published it successfully, I believe it. Obviously it wasn't successful at all. I reported this as a bug to the VS team.
So, making sure non of your files are in use is a good idea to check.

Related

How do I get an Azure API App to work if published from Visual Studio 2019 without API Mgmt in between?

I am using Visual Studio 2019 ver 16.7.2.
I have an API Project that is called JobBank.API. In Visual Studio, my App URL in the project settings is http://localhost://6705. I also have a Swagger file created and configured in my Startup.cs as: "/swagger/JobBankOpenAPISpecification/swagger.json".
I published the API Project using Visual Studio to an Azure API App Service. The URL is "http://jobbank-api-demo.azurewebsites.net. After I publish it, a browser windows comes up to that URL with a 500 error saying "jobbank-api-demo.azurewebsites.net can't currently handle this request.".
Also when I try that url with "/swagger.json" I get a 500 error.
What do I need to do?
There was a bug in the .net cores 2.0 version of this problem. The 3.1 version we are currently using, I personally tested it, and this problem should have been resolved.
I will post my screenshot first to see if it is the result you want.
From the pic, we can see I have deployed my test web on azure, and also can open swagger.json file, no 500 Error.
So, I think you should check your code. You can download my test code from github.
When you test my code, you should modify links in index.html file under wwwroot folder . And when you deploy the demo, you will get 404 error. Don't worry, you need to attach /index.html at the url.
When you finish all the operations, you will get the same result as mine.
Details encountered when trying to solve your problem:
When I modify default route in startup.cs file.
When I add these code in project, it will get 500 Error. So If your code has same configurations, I suggest you remove it, and use url rewrite.

Problems publishing site to localhost on windows 2008 rs server

I must preface this post by saying that I am not an experienced developer, I am in the process of learning through trial and error and a lot of google searches so detailed (step-by-step) feedback would be greatly appreciated. I created a website, which does not use a database, using visual studio 2015 and I am attempting to host it locally on a Windows 2008 R2 server.
I installed IIS and loaded the asp.net v4.0 framework. The site works fine, produces no errors when I test it and works after being published only if the visual studio is still running.
However, when I close the Visual studio and open my browser window to http://localhost:50044 (which is the URL listed in properties menu in VS), I also tried using port :80 and nothing. When trying to add Web Site via the IIS management utility I receive the following authentication error: ”Cannot verify access path (C:\Inetpub\wwwroot).”
I checked the permissions and windows authentication is enabled with read access, and all other permissions seem to be correct. I am at a loss, I'm sure it is probably something simple that I am missing due to my lack of knowledge and experience. Any help would be appreciated.
It's sounds like you are running on IIS express which in your case stops running when you close visual studio. Normal process is create a new website in IIS and point to the folder where your web.config is. You can then hack your host file (C:\Windows\System32\drivers\etc) so DNS works. Add an entry like "127.0.0.1 mytestwebsite.com". I hope that helps
So I figured out part of what was happening. I didn't realize that visual studio has built in IIS and was using that by default.
I ran VS as an admin, created a new project, then attempted to create a virtual directory thru VS under the project/properties/web tab. I selected local IIS and entered http://localhost/boc and it returns an error: unable to create vd. Web server http://localhost... Could not be found.
I then went in to the IIS manager and set up a virtual directory with no issues. However, when I attempt to reference it thru VS I again receive an error message.
Any ideas?

Web Service error - Status 404 not found

I have created a web service in Visual Studio 2015 (web api) that listens out for requests via a barcode scanner. The barcode scanner links to a database that provides information such as stock quantities etc, but this is just for background information. The web service is currently installed on my local machine and works perfectly, returning the correct values and posts data to a database.
I attempted to install the web service onto a server, copying over similar settings in IIS (only have basic knowledge using this), such as the bindings and ensuring the permissions were set up correctly. However when running the web service I recieved a "404 not found error and 401 unauthorized". After that, I installed Visual Studio 2015 onto the server to ensure it wasn't a build or publish error...same problem.
Below are some of the 'fixes' I have tried to help narrow down the potential problem.
Ensured the correct version of .Net, 4.0, is installed on the server.
IIS Manager - Authentication: Annoymous Authentication set to enabled.
IIS Manager - Directly browsing: set to enabled.
Set the correct permissions using 'Edit Permissions', granted full control to 'Everyone'
This is my first time creating a web service so up until now I have been using tutorials and making it up as I go along. I think it could be to do with the application pools set up? But because the solution works on my local machine and not the server has me extremely confused. Thanks in advance.

IIS error - this program cannot display the webpage.

Here are the details:
We have a dynamic data website using Telerik Open access, hosted through IIS 6. This application has been running fine with no issues in production. Recently, we added two new tables to the SQL database. These were added to the Telerik Open Access model and when tested in Visual Studio 2012 there was never any issues and ran brilliantly.
Then we published to production and when I browse to the application directly through IIS 6 to ensure it runs we get the error - "this program cannot display the webpage".
So we removed those two tables from the Telerik Open Access model and re-published and the Application runs great. So we re added the tables again and the same error comes from IIS.
This makes no sense as IIS normally gives an intelligible error. Why would IIS have an issue with two additional entities added to the Model but Visual Studio does not?
It looks like the model is somehow cached.
You could try restarting the IIS in order to avoid the issue with the new entities in your model.
We had a metadata file associated with the model, and it was not configured correctly. When we fixed it and re-deployed, it worked great. The strange thing is that Visual Studio ignored the error and it took publishing it to error on us. Strange.

Asp.net - publishing a web site is causing an access denied error

I am working in visual studio 2008 sp1 and trying to publish a web site to a local directory. I keep getting the following error :
Error 3 Access to the path 'C:\Users\name\Documents\Sandbox\BTNET\App_Data\BTNET.mdf' is denied.
My question is how do I determine what user account Visual Studio is running as? I have tried to give everyone, guests, and IUSR_ full control and I am still getting this error. It’s painful..
You must "run as Administrator" VS2008 and publish site
Bring up task manager (ctrl+alt+delete) and look for devenv.exe.You should see the user in the User Name column.
AFAIK (As Far As I Know), it's ASPNET account
Since you're having problems accessing the DB file, make sure all the connection to that database are closed. That file might be in use, which in turn will cause the error.
It sounds like either an application is open and using the file(i.e. Visual Studio, modifying the schema or data or an instance of Access) or the user publishing the files does not have access to the delete files.
The first scenario is more common.

Resources