Optimizing wcf service in IIS - wcf

I am hosting a ASP.NET web site containing a wcf web service in IIS 7. The web service is exposed using a .svc file that resides inside the web site's virtual directory.
There's section is this document about optimizing the web service performance by removing unnecessary http modules:
http://msdn.microsoft.com/en-us/library/ee377061(v=bts.10).aspx
My question is how can I do that in the web config without affecting the web site? My ASP.NET web site contains authentication stuff and definitely requires some of those modules (eg, FormsAuthentication). Is there a way to enable those modules only for the web site but disable them when the clients access the web service?
Thanks

You should separete your project into two (web and Service).
After that, create a website into IIS and add those two application separatedly, like that:
That way you can handle different configurations for each site, and configure the modules for a especific "project" (like wcf service).

Related

What is the need of external server in ASP.NET Core outprocess hosting?

In OutOfProcess hosting model, there are 2 web servers i.e. one internal web server and one external web server. The internal web server is called Kestrel and the external web server can be IIS, Apache, or Nginx.
When Kestrel is the cross-platform web server for the ASP.NET Core application, and support request from all platforms, then what is the use of external web server?
The IIS or apache contains a lot of advanced feature. For example, advanced logging, GUI ,failed request trancing and other feature. It is very easy to configure and find the logs more easily.
The Kestrel need all settings by the codes and if you need special feature, you need to develop by yourself or changing the codes.

Map WebApi directly to the website and not use IIS Application

I have lot of webapis which are developed and deployed independently.
Each API would have routing for ex:
api/FirstApi
api/SecondApi
These will be deployed under www.myapis.com/.
If I create application for each of the api(s) in IIS, I would access the api as follows
www.myapis.com/FirstApiApp/api/FirstApi
but I want to access it as.
EX: www.myapis.com/api/FirstApi
Or: www.myapis.com/api/SecondApi
I want to remove the application FirstApiApp OR SecondApiApp from the url.
Is it possible to configure this pattern in IIS?
You could have the following structure:
c:\inetpub\wwwroot\api\FirstApi
c:\inetpub\wwwroot\api\SecondApi
And then have a website in IIS mapped to c:\inetpub\wwwroot and inside the api folder you have the 2 applications configured like this:
This assumes that you should drop the api/FirstApi routing from your Web APIs and map them to / directly because the first part will be provided by IIS. If you don't do this the request will become www.myapis.com/api/FirstApi/api/FirstApi which is not the goal here.
This being said, personally I would recommend you against doing this. A better approach would be to have a reverse proxy such as nginx or HAProxy in front which will route requests to /api/FirstApi to for example backend_node:8080 and requests to /api/SecondApi to backend_node:8181. This would allow you to deploy your Web APIs in two separate website in IIS listening on two different ports and keep the routing job to the application layer and not the infrastructure.

Host to host multiple WCF services in same website in IIS 7.5?

How would I host 2 WCF services within the same web site ( i.e. same web application) ? I do not want to have each WCF with its own independent web site host.
WCF Services integration with IIS uses a .svc file for hosting in a web application.
You can create as many .svc files as services you created with WCF in the same web application, so you only need to create a .svc file for each WCF service inside your web project.
Maybe you could explain the implementation details services to know if this applies to you.

Directory access outside of wwwroot for a WCF service hosted on IIS

I've been working on a WCF service that is currently hosted on IIS. I need to get the WCF service to access a directory outside of the wwwroot folder.
Am I right in assuming that directory access outside of wwwroot is restricted to WCF apps hosted on IIS as it would be restricted for an ASP.Net application hosted on IIS?
If this is the case, what is the safest way of allowing the WCF service to acccess a set folder outside of the wwwroot?
BTW - I'm running in Mixed Transports Mode, not ASP.Net compatibility mode.
File access is going to be limited based on the identify of the application pool that is hosting your service. Your service will be able to access any file the application pool identity has access to whether it is in the root of your IIS website or not. If you want to access files within the root of your website using relative paths with something like Server.MapPath then you'll have to run your WCF service in ASP.Net compatability mode. See the following page for details on WCF with ASP.Net compatability mode:
http://msdn.microsoft.com/en-us/library/aa702682.aspx
I think that the best approach is to create another application pool for your service and assign a specially created account as the identity of your new application pool. Then give the needed permissions of the account to the folders and file you need to access. You can make the external folder a virtual directory of the site if you want to reference it with a relative path.

Can I host a wcf 4.0 website in IIS instead of as an application in IIS?

Most examples I see about hosting WCF in IIS have you create an Application under an existing website. I have a website in IIS, but the website uses a .NET 2.0 app pool, so I can't host the service as an application under the website. Is it better to create an empty website to just host the service or to create an empty website and then create an application under that empty website to host the service?
I have WCF running as a WebSite in both IIS6 and IIS7, and they work fine. They basically work exactly the same as any ASP.NET site; the .svc files are conceptually similar to .aspx pages, in that IIS calls over to .NET to process them, and all the core WCF stuff is in the assemblies in \bin. The web site is assigned to an App Pool where the actual processes run, just like a normal ASP.NET site. I don't think you need to make an 'Application' in IIS.
You don't need a new website - you can still host WCF in a 2.0 application pool - but in your project you'll need to set the target framework version to 3.5, instead of 4.0.