authenticate Lightswitch Odata service that uses forms authentication

廉价感情. 提交于 2019-12-13 06:18:30

问题


I created an OData service using VS Lightswitch with an endpoint like this:

http://mydevsite.com/lightswitchapps/mydata/products.svc

The service is secured with forms authentication. When I put the url into a browser I am asked for credentials.

I want to build a console app in C# to consume the service. But I can't find any examples of how to authenticate.

I've worked through this which consumes the Northwind service:

http://msdn.microsoft.com/en-us/library/hh868028%28v=vs.103%29.aspx

But I need help with the authentication.

Can anyone point me in the right direction?


回答1:


I had the same issue in LightSwitch OData Service.

Here is the solution :

    Uri uri = new Uri("https://localhost:5487/ApplicationData.svc/");
    var container = new MyNameSpace.ApplicationData(uri);
    container.Credentials = new NetworkCredential("username", "password");



回答2:


It seems that your question is similar to this one: HttpClient and forms authentication in C# Please reference it.



来源:https://stackoverflow.com/questions/22563839/authenticate-lightswitch-odata-service-that-uses-forms-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!