I am creating my first ASP.NET Web API. Created the application, build them and ran the application by calling the URL like http://localhost:35432/api/Sample?id=1&id=83 and returns the JSON file as response.
But I dont see anything with respect to this application on the IIS manager. Where do I find them or do I have to set up something. I am not sure how we will be deploying the application from DEV to TEST server.
Related
I use database first approach in this web app. When I run the project on my local device, it is perfect.
After I publish the web app to Azure, and click the page displayed data, it returns an error page:
I have deployed exact same solution on two servers, one is my own server in my basement and the other one is Microsoft Azure. The project is developed using Asp.Net Web Api 2.
On my own windows server running IIS 8.5 it totally works. For test, you can simply browse this link in your browser and see the error message {"Message":"The requested resource does not support http method 'GET'."} which shows the API has been hit.1
But exact same project on my Azure domain here, you just get a message saying
The resource you are looking for has been removed, had its name
changed, or is temporarily unavailable.
Everything about these two deployments is the same (to the best of my knowledge) and I was wondering if there is any further steps necessary on Web Api app deployment in MS Azure which I am missing.
I finally found the answer to this issue. If there are multiple apps deployed as one single website so each app is located in its own subfolder, you have to go to the configuration section of your web app on Azure and create virtual directories for each of those sub folders.
Ah, my problem was probably a common one. I was using
rootconfig = System.Web.Configuration.WebconfigurationManager.OpenWebConfiguration(null);
and that was returning the root web because the parameter was null.
When I ran it local that worked fine, but after I deployed the root Config was NOT what I wanted and my code was failing.
Switched to direct access via
stringVal = WebconfigurationManager.AppSettings["Foobar"].ToString();
Nice. Plus less overhead.
I have created Web application using asp.net MVC architecture.
I have used Web API for getting data from database. Both Web application and Web API are in same project. I have not published Web API separately on IIS.
When I am debugging or running the application through Visual studio it works properly. I have used below code to get data from Web API URL
TODOINfo[] lstToDoInfo = httpClient.GetAsync("http://localhost:65373/api/RESTApi").Result.Content.ReadAsAsync<TODOINfo[]>().Result;
In Above function I am passing url which consist of localhost plus fixed port number. Above code is working fine when running through in Visual studio.
I have published the same code on IIS by doing below changes.
TODOINfo[] lstToDoInfo = httpClient.GetAsync("http://" + sBaseUrl + "/api/RESTApi").Result.Content.ReadAsAsync<TODOINfo[]>().Result;
sBaseUrl value is "localhost".
After Browsing the application on internet explorer getting following error.
No MediaTypeFormatter is available to read an object of type 'TODOINfo[]' from content with media type 'text/html'.
Any information or suggestion regarding above problem is highly appreciate.
Try changing sBaseURL to "localhost/" +yourwebsite
another option would be to change: sBaseURL to: servername/yourwebsite
I have been literally stuck for hours trying to deploy a Web API app to IIS. I can not believe there are no useful tutorials online anywhere that I can find. Here is my situation.
I have a VERY basic Web API app. It is using .NET Framework 4.0. It doesn't do anything I just want to see the home page at this point.
I am developing it in Visual Studio 2012 on my local machine. I can hit my localhost and see the home page, even post some data through Fiddler works great.
I publish the solution using Build->Publish to my local file system.
I then copy and paste everything in that directory to my web server (actually using a repository but for simplicity sake)
I created a brand new application pool in IIS. .NET 4.0 Integrated.
I placed the folder that contains my published code inside of the directory of my main website. The folder name is WebAPI.
I created a new website in IIS, attached to that new app pool I created.
I start the website, browse it on localhost and everything works perfectly.
I try to go to the website externally "website.com/WebAPI/api" and get a
403.14 - Forbidden The Web server is configured to not list the contents of this directory.
I'm sure I'm doing something wrong, I've never deployed an MVC app to IIS on another server. I'm able to deploy it just fine on my local machine through IIS too. What am I missing? Thanks!
Edit: Yes, my server has other .NET 4.0 apps running just fine.
http://localhost/api
http://website.com/WebAPI/api
Is this correct?
If so, looks like it could be a path problem.
I have an asp.net mvc 2 application which works fine when run from visual studio either in release or debug mode. When the application is deployed to either a remote or local IIS 7 server in release mode it doesn't work.
The error displayed is as follows:
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Now this is a bit misleading however I have worked out why this error message is being displayed.
The application does not have a default.aspx as this is not needed when running mvc apps on IIS7+
I am using attribute routing which is explained in the link below which uses reflection to build the RouteTable. When interrogating the assembly the attributes are not accessible therefore the RouteTable does not get populated
Since there are no routes the web server attempts to list the directory contents and it does not have permission to do that.
Attribute Routing:
http://itcloud.codeplex.com/
ASP.NET MVC Routing Via Method Attributes
Now my question is what is preventing the application from being able to interrogate the assembly using reflection?
DaTribe
Lack of ReflectionPermission is a likely cause. Many hosting companies over-restrict permissions. Reflection is one that is often problematic. GoDaddy and RackSpace both restrict it.
What trust level is your application running? What hosting provider are you using? Do you have RDP access?