last day (15 days later) » 

5:59 PM
0
Q: Why do my wcf application can not use and save session?

SarlyHere is the interface and class of my wcf application.At first,I want to get the sessionId in my method by string sessionId=OperationContext.Current.SessionId But I find that sessionId is always null.So I try to use and save the asp.net session successfully like HttpContext.Current.Session.A...

 
WCF is stateless by design. You should avoid sessions if you can. But if you really have to, at least don't try to use ASP.NET sessions.
 
@chris, Can you tell me why don't try to use ASP.NET sessions?I have config it in the config file using aspNetCompatibilityEnabled="true".
 
This document describes, among other things, the difference between WCF and ASP.NET sessions: msdn.microsoft.com/en-us/library/ms733040(v=vs.110).aspx
 
I do really need to use sessions,no matter wcf or asp.net sessions.But both are fail for me.I still do not know why OperationContext.Current.SessionId is null in wcf sessions?
 
I trust you read the documentation thoroughly? Just to be sure: WCF sessions have to be explicitly intiated by the client.
If you are wondering why sessions generally are a bad thing: Among other issues, above all they make your service less scaleable.
 
5:59 PM
@chris,I have a wcf,and not everyone can call the wcf function.So I think I can use session to store the user that have the permission to call this wcf funcion.And if the session is null,he must have not the permission.It means that I have a methodA to verify all the caller.And the methodB is the really method that called by caller.
 
If you are using sessions for authorization: WCF offers much better, more scaleable ways to implement authentication & authorization.
 
Hi
Can you give me some example abount more scaleable ways to implement authentication & authorization?
I use session in MVC and it is OK,but when I change it to wcf,it is wrong
 
About the second part of your message: I would avoid sessions in MVC as well for pretty much the same reasons. But at least they are easier to implement because there is just one standard way to do it. But you don't NEED sessions in MVC either if you just use them for authentication & authorization.
About the first part: It very much depends on what binding you use, and whether you are doing certificate based or password based authentication
 
I use the default binding.it seems to be BasicHttpBinding
Now I do not have the authentication & authorization.
I just use the session to define whether the uses have the permission to call the mvc acton or wcf method.
Because the user is in one website,and my mvc acton or wcf method is in the other website.
 
6:17 PM
Well, first you should check out this: msdn.microsoft.com/en-us/library/ms731925.aspx
 
Ok,Thank you very much.I will read it firstly :)
 
To be fair, security is a very complicated topic in WCF because there are so many ways how to do it
It's much easier with ASP.NET MVC and Web API, because there is just HTTP / HTTPS to consider
 
Yes,I have finished it in MVC.
But my pm said I have to change it to wcf
 
Well, bad luck for you :-(
Microsoft seems to promote ASP.NET WebAPI in some ways as a successor to WCF, and I think that's a good thing - WCF is way to complicated, and SOAP sucks anyway
 
but my pm said wcf have the queue and multi-threaded parallel processing mechanism
Now I use mvc and many people call this actioin together in one time
and you know the speed is slowly
 
6:29 PM
I don't really know what he means by that, but concurrency is supported by both
 
queue is just like msmq
 
Ah - well, WCF does support MSMQ - to be honest, I don't have any experience with that
 
en en
Ok,I read some and will sleep now.If I can not understand ,I will ask you tomorrow.Thank you very much.Good night!
 
Ok, good luck with your project
 

last day (15 days later) »