liubiao4123 / servicestack

Automatically exported from code.google.com/p/servicestack
0 stars 0 forks source link

Implement Forms Authentication Using ServiceStack #66

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I am experimenting authentication with servicestack using forms authentication. 
Everything works fine except Session is always null. 
HttpContext.Current.Session returns null. 

Also aspnet_sessionid cookie does not get created.

I very much like what you guys are doing with servicestack and am planning to 
use in our project.

Am I missing anything? Is there a workaround. Help will be appreciated.

Original issue reported on code.google.com by Mehta.E...@gmail.com on 30 Nov 2011 at 7:44

GoogleCodeExporter commented 8 years ago
Hi, 

This deprecated group no longer gets monitored. For new Questions/Issues you 
should post them to the Google Group:

https://groups.google.com/forum/#!forum/servicestack

Ask a Question on http://stackoverflow.com or 

File an issue on the current GitHub project:
https://github.com/ServiceStack/ServiceStack/issues

Basically, ServiceStack does not make use of ASP.NET's session or Form 
authentication providers. 
If you want to use them you should host servicestack at a custom path, e.g. 
/api or /servicestack, etc.
http://www.servicestack.net/ServiceStack.Hello/#custompath

Then since anything outside of /custompath is a standard ASP.NET application 
that is unaffected by or visible to ServiceStack.
Once the session is initialized and you're authenticated you can make use of 
the session on the ASP.NET HttpRequest object either at:

var aspNetHttpReq = 
((HttpRequestWrapper)base.RequestContext.Get<IHttpRequest>()).Request;

or via the singleton HttpContext.Current.Request

ServiceStack also provides its own Authentication/Session/Caching provider 
models, you can see an example of this at:
https://github.com/ServiceStack/SocialBootstrapApi/blob/master/src/SocialBootstr
apApi/App_Start/ServiceStackFramework.cs#L138
We intend to publish more information on the new in-build Authentication 
services in the coming weeks.

You can also implement your own Authentication making use of the 
RequestFilters, here's an integration test example implemented with BasicAuth:
https://github.com/ServiceStack/ServiceStack/blob/master/tests/ServiceStack.WebH
ost.Endpoints.Tests/RequestFiltersTests.cs

Original comment by demis.be...@gmail.com on 30 Nov 2011 at 8:14