none
Unable to Successfully Host a REST Web Service under IIS on LocalHost RRS feed

  • Question

  • Hello there

    I am trying to develop a REST based web service to call from my Universal app.    I plan to put the web service on a server in due course, however for the moment I just want to get it running on my local PC under IIS.

    I am using Visual Studio 2015 Community and Windows 10.

    I have followed through the following article:

    http://www.developerhandbook.com/wcf/restful-web-service-using-wcf-1-of-3/

    Everything works as documented (except for a few adjustments I needed to make because of Entity Framework version issues).  When I run the service from Visual Studio, everything works correctly.  For example, I can successfully make calls such as:

    http://localhost:8085/BlogService/GetBlogPosts

    This works from both IE and fiddler.  When I run the web service project from Visual Studio, it runs the WCF service host utility.

    The article does not discuss how to deploy the web service.  I have followed through a number of other articles on how to install a web service in IIS, which I have done on my PC.   None of these work – when I make calls such as http://localhost:8085/BlogService/GetBlogPosts, I just get the standard 404 error.

    A lot of the documentation talks about publishing within Visual Studio using “Web Deploy”.  I don’t have a “Publish method” dropdown from which to select “Web Deploy”.

    Any help greatly appreciated.
    • Moved by Breeze Liu Monday, June 19, 2017 7:25 AM wcf
    • Edited by Geoff_Olding Wednesday, August 9, 2017 10:08 PM
    Saturday, June 17, 2017 9:14 PM

Answers

  • Hi Geoff,

    After checking the article, I found you are publishing the wrong project. The project for service is RESTfulTutorial.Service instead of Web, web is a client to request the service. In other words, you need to publish the RESTfulTutorial.Service.

    How did you launch RESTfulTutorial.Service?

    For a simple way, I suggest you follow below steps.

    1.Create a new WCF Service Application

    2. Change web.config according your current app.config in RESTfulTutorial.Service

    3. Modify the Service Contract, Operation like your service library

    4.Publish this to IIS

    In addition, if you have any issue about this way, I would suggest you post a new issue, and then we could focus on this specific way.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, August 11, 2017 2:18 AM

All replies

  • Maybe you should post to the IIS forum. I am sure people have deployed to IIS on servers on what you are trying to do.

    https://forums.iis.net/

    Monday, June 19, 2017 12:10 PM
  • Hi Geoff_Oldin,

    Compared with UWP, this case is more related to WCF. I have moved it there.

    Best Regards,

    Jason


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 20, 2017 1:44 AM
  • Hi Geoff_Olding,

    >> I have followed through a number of other articles on how to install a web service in IIS, which I have done on my PC.

    It would be helpful if you could share us more detailed description about your steps to install in IIS.

    After you install it, you need to access it from IIS address, it seems you access to the development address. Try this “http://localhost/BlogService/GetSomePosts”. The address depends on how you deploy the service. You could open your IIS to check whether it is published correctly.

    Could you share us a screen shot your Publish method? You could Right-Click RestFulTutorial.Web->Click Publish and you will get Web Deploy.

    I think you could follow below steps.

    1. Run VS as Administrator

    2.Switch to Restful Web project property, and turn to Web Tab

    3.Change IIS express to Local IIS

    4.Click create Virtual Directory

    5. You will install the Service in IIS, it will run under IIS when you launch VS

    In addition, it is a little strange about your URL, could you share us your simple project? As my experience, the URL is like http://localhost/WCFRest/RestService.svc/getvalue?value=123. The .svc is the WCF Service file extension.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 20, 2017 3:20 AM
  • Hello there

    Many thanks for your reply, and apologies for not getting back to you sooner.

    I have tried installing the application under IIS in a variety of ways, including the in the way that you suggested:

    (I pressed “Create Virtual Directory”).

    This does not work (entering both http://localhost:8085/BlogService/GetBlogPosts and http://localhost/BlogService/GetBlogPosts result in the standard “Not found” errors in both IE and fiddler).

    Installing the service under IIS in the way you suggested means that I am unable to start the web application:

    As far as I can tell, the web-site has been installed correctly under IIS:

    I get the following when I right click on the Restful web application and click “Publish”.  I do not know what I am supposed to do next.

    I am calling http://localhost:8085/BlogService/GetBlogPosts, as described by the article.

    I would be happy to send you the project, if you would like to tell me how.

    Alternatively, I have been looking for a simple step by step article on how to develop and deploy a simple REST based web service using Visual Studio.  If you know of any, please let me know.

    Many thanks

    Geoff Olding


    Wednesday, August 9, 2017 9:39 PM
  • When you deploy an Web application to local IIS via Visual Stuido, then VS must be runnig with Administrator rights under UAC, before the virtul directory for the Web application is created on local IIS.

    Or you log into the machine with the super administrator account, start VS and then create the Web site through VS.

    Wednesday, August 9, 2017 10:06 PM
  • Hello there.

    Yes, I am running Visual Studio with administrator rights.

    Wednesday, August 9, 2017 11:57 PM
  • Hi Geoff,

    If you choose the web site in IIS->Content View->Select ServiceName.svc->Browse, will you get any error?

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, August 10, 2017 1:45 AM
  • Hello there.

    Yes, I am running Visual Studio with administrator rights.


    You are using Vista or above, UAC is enabled and you get the UAC prompt to escalate privileges when starting VS? If that is not happening, then you are not running VS with admin rights. If doing anything from the desktop, then you are just a  user with Standard user rights even as admin with UAC enabled and until UAC escalation.   
    Thursday, August 10, 2017 11:28 AM
  • Hello there

    There is no .svc showing in IIS.  It has published the web-site, not the service:

    Thursday, August 10, 2017 6:31 PM
  • Hello there

    I am running Windows 10.  A short-cut to Visual Studio is on my desktop.  I right click on it and select "Run As Administrator".

    This prompts me with Do you want to allow this app to make changes to your device?

    I choose "Yes".

    Regards

    Geoff Olding

    Thursday, August 10, 2017 6:42 PM
  • Maybe it would be good if you looked at WebApi that is Restful and Json based. You can always but WCF  Web services behind it, the svc kind in the solution infrastructure.
    Friday, August 11, 2017 1:21 AM
  • Hi Geoff,

    After checking the article, I found you are publishing the wrong project. The project for service is RESTfulTutorial.Service instead of Web, web is a client to request the service. In other words, you need to publish the RESTfulTutorial.Service.

    How did you launch RESTfulTutorial.Service?

    For a simple way, I suggest you follow below steps.

    1.Create a new WCF Service Application

    2. Change web.config according your current app.config in RESTfulTutorial.Service

    3. Modify the Service Contract, Operation like your service library

    4.Publish this to IIS

    In addition, if you have any issue about this way, I would suggest you post a new issue, and then we could focus on this specific way.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, August 11, 2017 2:18 AM
  • Hello there

    Thanks for your suggestion.  I will try these steps, however the chances of my being successful are essentially zero.  I have unsuccessfully tried hundreds of similar things over the last 8 months. 

    As I say, all I need is an article that actually successfully takes me through the simple steps of:

    1 - writing a simple REST based service under in Visual Studio

    2 - hosting the service under IIS.

    If printed, I do not believe such an article would be more than 2 or 3 pages of A4.  I would be extremely grateful if you could contact the appropriate people at Microsoft to determine whether such documentation is available.

    Many thanks

    Geoff Olding

    Friday, August 11, 2017 9:31 AM
  • Hi Geoff,

    Have you thought about "self-hosting" your web service instead of using IIS? Just a thought ... and, in case you're interested, read my blog post:

    http://geek-goddess-bonnie.blogspot.com/2013/10/easy-windows-services.html


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Saturday, August 12, 2017 4:09 PM
    Moderator
  • Hi Geoff,

    Have you made it work by my above suggestion?

    Since we have narrowed down this issue to the wrong published project for your original issue, if not mind, I would suggest you mark the helpful reply to close current thread.

    And for publishing WCF Service, I think you could post a new thread, and then we could focus on this specific issue.

    For the document description, I think it could be achieved by my above suggestion. If you failed to make it work with my above suggestion, I will try to show you the detail step by Image or document as you like.

    Please feel free to go with WCF, we will try to help as our best.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 14, 2017 2:17 AM
  • Hi Edward

    Thanks for your reply.  I followed through your suggestions without success.

    I created a WORD document containing a complete description of what I did.  I am unable to create a post containing the contents of this document.

    I cut down the post until it contained 154 words and two screenshots.  This forum refused to post it, with the error "Body must be 4 to 60000 characters long".  My post is approximately 1/60th of this stated size limit.

    I could email this document directly to you.

    Regards

    Geoff Olding

    Tuesday, August 15, 2017 9:03 PM
  • Hi Geoff,

    You could upload the document to OneDrive and share us link here.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, August 16, 2017 1:47 AM