400 bad request when access ASP.net web api via computer name on IISExpress - asp.net-mvc

I'm getting a 400 bad request error message when accessing an ASP.net web api via a url that uses the computer name. When I use localhost it works fine.
I'm using the iisExpress for visual studio 2012.
Any help is appreciated! Thanks in advance!

I found the answer to this from another post on here. I had to update my IISExpress' applicationhost.config file and add a binding with my computer name on it.
The link to the other post is here: Configure IIS Express for external access to VS2010 project

If you prefer not to change configurations, you can use our free VS extension called Conveyor
https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti

Related

Can IT Hit WebDAV Lib be used with ASP.NET Web API 2 in the same Project?

I´m currently evaluating Web Dav Product for .NET and I´m really impressed. I only noticed that when I´m integrating the sample code (Asp.NetFileSystem) into my existing ASP.NET Web API 2 Project, it doesn´t work with Office Word directly as a save target.
We have Web API 2 with Windows Authentication and CORS Headers on.
Windows Explorer can open and Navigate the WebDAV Folder and I can create new files there. But when I´m saving from word directly, I get errors in Word that the network path does not work / exist. I tried to debug it but it happens
I separated the WebDAV part in it´s own project for test purposes and it works without the problems.
Am I using it wrong in the context of Web API 2, or is this an unsupported usecase?
I´ll try to get fiddler logs to.
Thanks a lot!
Thanks to the IT Hit WebDav we were able to trace the problem down. To work correctly, OPTION requests have to be processed by the WebDAVHandler. We have a custom module which intercepts OPTION requests to handle CORS. Because of our Module, the WebDAVHandler was not able to add the necessary headers, and Office opened the files readonly.

MVC Web App using Web API do not work after deploying on IIS

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

How I do for my project using Local IIS

I'm using Visual Studio 2013, Windows 8.1 and IIS 8.0.
In properties settings, I have set the server to Local IIS and I set the project url to localhost/myProject.
When I debug the project I get the following error shown below:
Unable to start debugging on the web server. The web server could not find the requested resource.
Click Help for more information.
OK Help
and when I start without debugging I get this error:
Error HTTP 403.14 - Forbidden
can somenone help me?
You need to give proper permissions to the directory containing your application. Give read, write, and modify permissions to IUSR and IIS_USERS. This should help to resolve your issue. Did your application work using IIS Express? If it didn't work using IIS Express then I'll need more specific information on the issue you're running into.

Access site from public ip

When I debug my asp.net mvc3 web application on http://localhost:11118/ using microsoft visual studio and it works perfectly.
But when I try to view it on http://MYPUBLICIPADRESS:11118/ I get a HTTP Error 404. The requested resource is not found. message. I portforwarded port 1118 correctly. I have no problems doing the same using apache.
How can I get this to work?
The Visual Studio internal server only accepts connection coming from localhost. You should use IIS Express (and manually change the config file) to let it accept connection using other hostnames, including the computer name.
You can read more about setting the server of your preferences on MSDN

Unable to start debugging on the web server. The web server could not find the requested resource

I'm having this error trying to debug my ASP.NET MVC app. I've set the app to "Use Local IIS Web server", and selected ASP.NET as the debugger. Running the site without debugging works just fine, but when I try to debug, I got this error:
Unable to start debugging on the web server. The web server could not find the requested source.
I'm using Visual Web Developer 2008 Express Edition.
Does anyone know how to fix this error? Thank you.
For those encountering this with Visual-Studio 2012 and/or Windows 8 do the following.
You have to add .Net 3.5 (or 4.5) to your Turn Windows Features on or off window. You get to it via :
Control Panel -> Programs -> Turn Windows Features on or off
Click the Asp.Net 3.5 and the Asp.Net 4.5 check box in the IIS > WWW Service > Application Development Features folder.
Go to your web project's properties, then the "web" tab, then make sure that you're using the Visual Studio Development Server and not Local IIS or the custom webserver. I'm on VS2010 with Win7 and another developer was developing using a custom webserver URL and not the VS Dev Server
Sounds like you are trying to develop on IIS and not iis express or development server. If you are using asp.net mvc 4, make sure that the Application Pool is framework 4. If not just make sure that your app pool it matches your asp.net mvc version.
I had the same problem, and i fixed this way:
Go to IIS Manager -> Go to the site -> Error Pages -> Actions: edit feature settings.. -> Make sure you checked "detailed errors for local requests and custom error pages for remote requests".
IF you are using IIS6 and did the add mapping for .* in IIS trick to get MVC working, when you added the .* handler to iisapi.dll you forgot to uncheck the "check the file exists" check box.
Also, be sure that the URL you're configuring in Visual Studio matches your Host Headers (Edit Bindings) in IIS. This tripped me up for about an hour this morning before I realized my very stupid error.
Having maxRequestLength or maxAllowedContentLength set to a ridiculously large or small value will also trigger this error.
What i did, was just type the IP address in the web tab instead of "localhost"
This happened to me today. Turned out to be that the default website was stopped in iis. I had been working on a second website that didn't use it for a long time. Simple fix but took me a while to see it!
The root cause for this error can often be that the Windows Service W3SVC is not started. Check that this service in Windows Services console (services.msc) is started. In IIS you will now see the the Start icon is greyed out. This means that the W3SVC service is running.

Resources