IIS 7, MVC2 Web Service, HTTP 405 Error on PUT - c#

This is a similar question as IIS 7.5, Web Service and HTTP 405 error but a little different. Instead of a WCF web service, I've got an MVC2 web service that returns a 405 error when a PUT is used in the request. And, in my case, POST works just fine.
I'm guessing I need to either add or tweak an IIS 7 Handler Mapping to get PUT to work but my hosting provider hasn't been much help. Anyone out there run into this and know how to get PUTs to work in an MVC2 web service running in IIS 7? My apologies if this has already been answered, I've been searching all day and haven't found the magical answer.
Any help would be greatly appreciated...

We had the same problem, and the solution was adding an element into section in the Web.config file:
<remove name="WebDAVModule"/>

Have a look at https://serverfault.com/questions/93424/how-to-enable-put-and-delete-in-iis7/93428#93428
dario-solera:
You can take a look at the "Handlers
Mappings" sections at either the
server or site level (IIS group).
Select a mapping for an extension
(e.g. .aspx) and select "Edit" from
the context menu. The "Verbs" tab
allows you to specify verbs to accept.

Related

IIS Express- C# Angular 2 Web Api functionality changes after publish

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.....

HTTP 404 IIS when publishing on IIS

I'm having some troubles trying to find out what to do:
I published a directory with some .aspx pages on IIS on :8081 :
image - localhost:8081
But when i click on a page or try typing it, i get an http 404 :
http 404 - image
Maybe some IIS configurations, but i cant find it anywhere, if someone could help me i would really appreciate! Thank you all!
You can setup your bindings by following the instructions in this post:
How to access multiple website using different bindings on IIS 7.5
Also, IIS Express will assign a random port when debugging, and this will not work when the app is actually published.

WcfWebApi in Windows Azure WebRole always returns 404, but is fine locally

I'm stuck on the dreaded "it works locally" issue.
I have used NuGet to install the WcfWebApi into an Azure WebRole.
This is a WebForms website.
Global.asax.cs Application_Start calls RegisterRoutes().
RegisterRoutes() contains:RouteTable.Routes.Add(new ServiceRoute("MySvc/TheService/", new WebServiceHostFactory(), typeof(Services.TheService)));
The Service's Interface contains:
[OperationContract]
[WebGet(UriTemplate = "/hello", BodyStyle = WebMessageBodyStyle.Bare)]
string Hello();
The implementing class just returns "hello", so if I now navigate to: http://localhost:49831/MySvc/TheService/hello - i get "hello" returned. OK.
If I now publish to Azure and try the same url (obviously with xx.cloudapp.net/ etc) I always get a 404.
I have used the WcfWebApi before in the past - but always in a WCfWebRole. Does this make a difference? Why does it work locally? It must be something to do with Azure then?
Any advise appreciated. Thanks.
Edit: well, as per #Rajesh's suggestion I ran Get_HostedServices, which listed the hosted-services urls, eg: https://management.core.windows.net/mysubscriptionId/services/hostedservices/the-nameOfTheApp. Not really sure where this is going...
In utter desperation I added a .svc file to a folder in my web app, plus all the (horrible) system.serviceModel services and so on that one needs for REST style configuration. This all works.
I don't want to close this question though as it's not been answered as such and I am curious as to what has happened. Thanks everyone for responses so far. If I do find an answer I'll update.
I thought about your issue, Could you try to run your app locally using IIS or IIS Express? (IIS express isn't available out of the box, you must install it, but is easier to use with VS)
The url you provided lead me to think that VS uses either Cassini (Visual Studio Development Server) or IIS express. Be aware that Cassini doesn't work exactly as IIS, whereas IIS Express does. Your Azure web role will run under IIS, which could explain the different behaviors you are experiencing.
Furthermore your url doesn't look like a Windows Azure emulator url (the domain should be something like 127.0.0.1:81 .
I suppose your project is a windows azure project. When testing, are you sure you are starting the Azure project and NOT the web application project?

ASP.NET Web Service parser error on server, not locally

EDIT2
Looks like I can't read properly, disregard this post, I will try to make a WCF service instead.
Thank you
EDIT:
Ok it seems I should start learning MVC instead. I tried getting into it before when I could't get this to work but maybe I didn't try hard enough because I already completed my web services and didn't feel like starting over before I knew if the problem was trivial.
For those who are interested:
What I am actually trying to accomplish is to create a database with a dozen different highscore tables which I will be able to retrieve from my Android app as JSON. So far I have an XML database and a webmethod for asking if a score is in the top 50 on a specific highscore table. One for submitting your score, and one for retrieving the entire highscore to show in the app. I also have a simple interface for adding, removing etc from the database.
Updated question: Will I be able to reuse some of my code if I create an MVC project and how do I put said project on the server? can it be done with an FTP client or do I need to use Web Deploy, IIS or web matrix or some other software? and what are the requirements of the server?
Thank you so much for the help :)
----------Original Post--------------
Recently I have been trying to learn how to create a web service in Microsoft Visual Web Developer (2010 express on win7 64bit) in a web application. I have a few very simple JSON web methods and when I run the project locally from Visual Web Developer it works like a charm, they return the correct values etc.
But when I transfer the project to my windows server running .NET 4.0 (which is the same as my target framework in this project) I can't access the web service anymore, the .aspx web pages work great but the .asmx web service shows the following error:
(I can only post two hyperlinks yet so I removed this image)
That line 1 is the only line in the .asmx file btw. I have tried putting the Namespace.Classname there instead but the error remains. (Test.DBWebService instead of just DBWebService)
I haven't changed anything in the code, this exact code does work on my computer. I have tried things that helped others with similar issues, like the build options:
Before running startup page: Build Web Site
Target Framework: .NET 4.0
Build Web Site as part of a framework Checked
which I assume should be configured like that.
My web.config looks like this:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation targetFramework="4.0"/>
<customErrors mode="Off"/>
</system.web>
<appSettings>
</appSettings>
<system.serviceModel>
<bindings/>
<client/>
</system.serviceModel>
</configuration>
This is the .cs file for the web service and an example method which works locally but can't be accessed on the server.
http://i.stack.imgur.com/4T6pq.png
What could possible create this problem? Am I missing something vital here because I am not very experienced. I have tried for days to get this done and even asked my web hosting company but they said they don't help with programming related issues.
If you are just now learning web services, then you should stop right now. You've made a major mistake.
You are using "ASMX Web Services", a technology which is all but obsolete. No new development should be done using ASMX unless there is no other choice.
Another mistake you are making is in using the web site "project". I strongly recommend you not use those for anything other than simple sites, and you might want to avoid them for that purpose in any case. Among other things, they have this precise issue with not building what you think they should build when you think they should build it.
Use a web application project instead, using "Add New Project" instead of "Add New Web Site".
Most probable causes of your issue are:
- wrong configuration of the site (application) within the IIS. My guess is that you are deploying onto an application but for some reason the application is not correctly created and the ASP.NET is unable to initialize the /bin folder where the binaries should exist
- wrong configuration of the IIS/ASP.NET. Find another machine with similar configuration and check your site there. If it works correctly, you could go back and try to find/resolve issues with your local ASP.NET configuration.

IIS 7.5 finds the local web site but can't load it

I am having this strange problem:
I have just developed a WCF service (on VS2008) and created a website (ASP.net) to use that service. When I launch the website from VS2008, it works fine and I get the "You have created a service method", but if I try to open that service using IIS then it is not able to load the website at all. I get a message that "website found, waiting for reply", but the browser is not able to load the service at all.
Any help will be greatly appreciated!
There was problem with my IIS 7.5, in that ASP.NET was not registered for IIS. The following article was helpful: http://msdn.microsoft.com/en-us/library/k6h9cz8h.aspx
I used aspnet_"regiis -i" command and the websites started loading. Thanks for all the help guys!
A few troubleshooting items
Make sure in inetmgr under Web Services Extension that the required frameworks are unblocked.
Enable tracing to watch the messages
Enable exception details in faults
Make sure you are running the website under correct framework (under website properties)
In web.config, clear and add handler svc-Integrated-4.0

Categories