I'm new to using Visual Studio to run a web api. I have an MVC Web API which I am trying to call locally but keep getting a 404. I am sure the API works fine because a friend of mine has hosted it on another server and I can call it fine. However, I am not sure how to get it running locally. Will building the code automatically get it hosted?
I am trying to call:
https://localhost/MyAPI/Action
Action is one of the action methods in a controller that should return "hello" but I get a 404 when trying to call the API. Any idea what I'm doing wrong here?
Related
i deployed my class library to azure.
the api has a class library as a dependency, when i work locally with iis everything works.
the problam is when i deployed the api to azure, every call to the api thet makes the api use the class library fails (status code 500) , when i make a call to the api and it has nothing to do with the class library it works but for some resone i cant call the use the class library from the api in azure.
i have tried to set the copy local veribal to true but could not find where it is (if thet is relevent)
thenks in advence for your help!.
According to the MS DOC
Getting 500 internal server error
The app starts, but an error prevents the server from fulfilling the request.
This error occurs within the app's code during startup or while
creating a response. The response may contain no content, or the
response may appear as a 500 Internal Server Error in the browser.
The Application Event Log usually states that the app started
normally. From the server's perspective, that's correct. The app did
start, but it can't generate a valid response. Run the app at a
command prompt on the server or enable the ASP. NET Core Module stdout
log to troubleshoot the problem.
Please refer the links for more information On azure web APi show 500 internal server error , How to resolve error 500 on Azure web app | SO THREAD and 500 internal server error on web app| MS Q&A
So I have a C# MVC Web API and Web Application that is an all-in-one project. I've created something similar to this in the past but the Web Application and Web API were two different projects with two different URLs.
For example:
The Web Application would be hosted at mywebsite.com/webapp
The Web API would be hosted at mywebsite.com/webapi
Any time I wanted to call the Web API from the Web Application all I had to do is send an Ajax request using the URL mywebsite.com/webapi/api/getdata
However, with my current project it's all-in-one. So in testing I would simply call /api/getdata and it would work just fine in Visual Studio debug. But when I deploy this site for testing and actually host it all my API calls are met with HTTP 404 errors.
So how do I call the Web API when the Web API doesn't have it's own distinct URL?
In IIS I converted the folder to an application and then made sure to switch the calls from
mywebsite.com/api/getdata
to
mywebsite.com/myproject/api/getdata
and it's working now.
Credit to #mxmissile for pointing it out.
First time when I created Web API project(MVC pattern) and I created few API controllers and called from html page(Ajax call),I am able to call all APIs and get the data.
But second time I've created two separate solutions one is asp.net Web API and another is MVC Web application.
Now I'm running both the projects in my machine and trying to call web APIs from MVC application, it's coming 405 method not allowed client side error.
Can anyone help me with this scenario.
Anything extra I need to configure in my server Web API to be called from different application?
I have recently published my C# .net core Angular 2 web application to an IIS Server. However, the Web Api that I am calling is not working correctly. When I call the Api, a file is supposed to download however, the file does not render correctly.
I am sure that the api is being called as I am not getting a 404 error. When I run the project on my localhost, it works fine, but on the live site it is not working.
One more thing, when I enter information that should normally cause an error in the web api, it is not throwing me an error like it does in the localhost. It is as if the api is failing but when it is published to IIS it doesn't recognize the error in the angular observable. If anyone has any ideas on why this is happening or how I can debug this it would be appreciated. Thanks
Please run the WebApi from IIS individually and check the error.
Please check the file size while downloading because you need to
configure in webconfig file, if exceed default configuration.
Please check in Angular you have subscribe to that observable.
If you can give more details on this. It can help us to provide
more information like specific error and so on.....
I am trying to configure mono mod asp server for webapi. It's working fine with get method but Post method gives me strange error.
What I did is I simply created webapi default application and used its default apicontroller without any modification.
Get and Post api is working fine on IIS server. Tried to find the solution but got stuck very bad.
Please help me out.