3

Good old Microsoft documentation at it's finest. Does anyone know of any resources that explains how to deploy Web Api with Asp.net Web Forms application. I have the web api in a separate class library and I call using jquery. I don't want anonymous users to be able to access this service only the application. Do I want to use self hosted? How do I lock the service down? Awesome examples showing how to use, tons of videos but nothing on deployment.

tereško
  • 58,060
  • 25
  • 98
  • 150
Fab
  • 904
  • 2
  • 14
  • 38
  • Are you looking at how to authenticate the service using credentials if it is deployed as a public service ? – Nishanth Nair Feb 04 '13 at 23:43
  • Form Authentication is good enough in this case. Imply that you uses Form Authentication for your ASP.NET Web Form app – cuongle Feb 05 '13 at 03:22
  • How to I deploy the web api for web forms, I'm using forms authentication, I guess I can use the authorize attribute for the authorization piece of it. How do I deploy to IIS 7. Standalone deployment? I don't want it available to the public, I'm only using it to pass data to jquery ajax. – Fab Feb 05 '13 at 04:06
  • 2
    Is your question about deployment or authentication + authorisation? They're two very different issues. – Snixtor Feb 05 '13 at 05:34
  • try to decompose your issues and ask specific questions. You are asking about a few separate things here. – tugberk Feb 05 '13 at 11:07
  • What are the best practices for deploying the Web API Project to IIS when the project is within a .Net 4.0 Web Application Solution? I want to lock the service down so only the Web Application Project within the Web Application Solution can use it or access it. – Fab Feb 06 '13 at 00:50
  • Its a service layer within the solution, I only want the web application that is using it to be able to access it. Anyone else would get access denied. I guess I'm asking is can I scope a Web API access to a specific application? – Fab Feb 06 '13 at 00:52
  • I don't want to create a separate IIS web for the web api, I want the web api to run within the same IIS as the web application. – Fab Feb 06 '13 at 00:53
  • When you say you you "only want the web application that is using it to be able to access it", do you mean the applications *server-side* or *client-side*? It's pretty common for a web application to access a Web API service through jQuery (client-side). If your web application already uses forms authentication, then it makes sense to extend that model to the Web API service too. If you're wanting to isolate the Web API service so only the *server-side* of your application can call it, then that's a bit different. Is that what you're asking? – Snixtor Feb 10 '13 at 21:17

1 Answers1

0

You don't have the right architecture for what you are describing, but what you have is right.

If you are calling web services from the client side (using jquery) then your web service must be public facing.

What you are describing is a web or WCF service in a service oriented architecture. That service would most likely live on a different server and be on an internal network, etc. Even if it's on the same server your requirement is that it is not publicly accessible - thus none of your jquery would work since that request is being initiated by the user and users can only make requests to public facing services.

The comments about using forms authentication to protect your service calls are right. jQuery will include the forms authentication cookie for you when it makes AJAX calls so you shouldn't have to change much on the client side.

Rush Frisby
  • 11,388
  • 19
  • 63
  • 83
  • Thank you. I didn't realize either until I got deeper into web api that I could include the authroize attribute. Even if it is public facing I wanted users to be authenticated to use the service. This is what I have been looking for here: http://stackoverflow.com/questions/12412163/minimum-files-needed-to-deploy-webapi-server-side I understand it now. I wasn't clear on authenticating to the service or what is required to deploy just the web api, what is the min requirements to deploy web api – Fab Mar 06 '13 at 20:28