WCF add new setting for each call - asp.net-mvc

I am facing a problem and I don't know if my solution is do-able. I have an ASP.NET MVC app which do request to a WCF service (both are hosted in IIS).
In the web app, I identify each user by Windows authentification and get their groups, roles, etc. from active directory.
BUT according to user groups, I need to change some settings in my WCF service. In my idea I'm looking a way to change the settings of WCF service (it need to be in the web.config, mandatory) and I'm really not sure if it's possible, because I think each call to the WCF should create a new instance of web.config, but for now it's just a simple file.
What do you think ?
Thanks !

Related

Web Services in ASP.NET MVC 4 Application

I've a web site developed using MVC 4 ASP.net application. I'm new to .net platform & I want to add web service which would return me operating system name of users device based on certain input.
Assuming I've logic to capture OS information using inputted data, how do I go forward in building this web service?
Do I need to have a complete separate solution file which will have a web service or in existing MVC 4 asp.net application itself, should I create a new project which would be of type "WCF Service Application"? Again I don't know much about WCF service either, if I use it, how would the URL be accessible, etc?
Can anyone give me some insights?
Note: I've also a separate REST web service which is a completely separate solution with separate projects but deployed on same IIS.
Thanks in Advance!
You don't need to create a WebAPI project just for what you described (i'm assuming one or a few end points).
Simply use MVC controllers that return JSON for example, this way you deal with a single framework.
Reasons to move to Web API is if you need support for CORS, need content negotiation for results etc. From what you are describing it's completely fine to stay with MVC.

Is it possible to get SimpleMembership to call a web service?

My web database server is being moved from the DMZ to the company LAN (don't ask why!). The downside of this is that my MVC 4 website is now gonna have to talk to an app server with web services (or web api) to get to the database. This isn't a major headache for most of my stuff, but I'm using the SimpleMembershipProvider for user authentication and that seems to need direct access to the database.
Is there any way to get SimpleMembership to talk to a web service or do I have to use a custom membership provider instead ?
I'm faced with the same situation, and while I haven't written or tested the code yet, I'll be writing a class to inherit from SimpleMembershipProvider and overriding the methods to call methods from the service (web api).
Is this the approach you ended up using?

Asp.MVC and WCF mixed authentication

I've got WCF web services hosted in an ASP.NET application. For the asp.net
part I'm using Forms authentication for the web services I want to use
Windows authentication. After configuring this the caller of the
service is getting redirected to the login page of the web app. I have tried to
exclude the folder hosting the WCF web services but could not get it working.
Can this be configured or do I have to host my WCF as separate site in iis?
Edit
After some more googling I found that its is posible but its not as easy as i would like it to be :) The part I especialy dislike is that my app has to have this wrapper in GC or app has to have full trust permisions :(
http://mvolo.com/blogs/serverside/archive/2008/02/11/IIS-7.0-Two_2D00_Level-Authentication-with-Forms-Authentication-and-Windows-Authentication.aspx
Ill try it and let you know how it went.
Did you setup your WCF bindings correctly in the web.config?
Here's a link on how to configure this:
http://www.codeproject.com/KB/WCF/WCFBasicHttpBinding.aspx
Do you have the ASP.NET compatibility mode disabled for the WCF Services ?. If it's enabled, ASP.NET will try to authenticate the user first. Otherwise, it should go straigh to WCF.
The solution I googled works, but Im not going to use it because application I made is not supposed to have full trust permisions and I also dont want to place the wrapper in GAC. So the solution I ended up with is split WS and asp.mvc app into two sites on iis.

WCF REST Web API and MVC on same server and port

I'm looking at putting together a REST based system which still has a standard browser style access. My desire is to have both of these on the same machine, but what are my options?
Use IIS to host both the web-site and the REST service (different URIs, e.g. http://mysite.com/ and http://mysite.com/api
Use IIS and some magic I don't yet know to have two domains mapped to the same machine but different services (e.g. http://www.mysite.com and http://api.mysite.com
Combine the two technologies into a single service (that perhaps uses routing tables to direct the requests to MVC or WCF where appropriate).
My preference would be the third option, this would allow me to have a single code-base and single repository accessing. The WCF page on codeplex mentions in its release notes, "not tested with MVC3" - is this suggesting that this is a possible approach?
I'm not keen on using MVC for the REST implementation as it is intended that the majority of interaction with my site goes via API, so I want that as the focus.
I've ported the contact manager to use MVC 3. It definiately works though we've not done exhaustive testing. The one thing in general to cognizant of with regards to web api is that both MVC Routes and Service Route are greedy. If your default route is first then MVC will try to grab your HTTP Service requests. One thing you will want to do is put your Service Route first before your MVC routes. If you run into additional issues, you may need to use custom routing constraints.
In http://webapicontrib.codeplex.com there is a sample that works with MVC 3. It is in the Samples/experimental folder. However, it was built with a custom version of WCF Web API. I don't believe it needs to be though. I've been meaning to get the author of the sample to switch it over.

using WCF in asp.net MVC

can we use WCF in Asp.net MVC and how can we use?
Sure you can - you need to learn the basics, e.g. from this site here:
http://msdn.microsoft.com/WCF
I can't possibly explain all you need to know here - go and learn the basics of WCF, and if you have concrete problems / questions, come and ask them here!
Do you mean, can my ASP.NET MVC projects be WCF clients, or contain WCF servers?
If the former, sure no problem. Right click on Solution Explorer, 'Add Service Reference', enter the URL to a running service (or pick an existing one from within another project in your solution) and away you go.
If the latter, that's fine as well. There is nothing stopping you from adding a WCF service via (perhaps SomeService.svc) 'Add\New Item...' (WCF Service, AJAX-enabled WCF Service, or Silverlight-enabled WCF Service are your options) or by hand. You need to bear in mind that the WCF service in this case will be hosted in IIS so there are some restrictions you need to be aware of depending on which version of IIS you are deploying to (ie. in IIS 6 only HTTP protocols are supported for your WCF services, some of the more esoteric WCF options may also be limited).

Resources