0

I have asp .net mvc application with authorization system. Console(or winforms, doesn't matter) application uses WebRequest to post some data to server. Everything is ok, but know I need check, is user authorized, and return it. So, I'm cheking

User.Identity.IsAuthenticated

and it returns false. But in browser I'm authenticated and this method obviosly works in mvc-aplication, but when console application sends requests, it doesn't work. How to solve it?

I'm using it to load my files

Community
  • 1
  • 1
lenden
  • 800
  • 2
  • 14
  • 38

2 Answers2

0

Essentially, your console application needs to also send the "forms authentication cookie or ticket" in the request to your web server. This post might be helpful http://www.codeproject.com/Articles/187198/Various-Clients-and-Forms-Authentication.

0

When you create your web request (I assume you mean an HttpWebRequest), make sure it's configured to send windows credentials.

For HttpWebRequest, you would set UseDefaultCredentials to true:

Set this property to true when requests made by this HttpWebRequest object should, if requested by the server, be authenticated using the credentials of the currently logged on user.

Damien_The_Unbeliever
  • 234,701
  • 27
  • 340
  • 448
  • It doesn't work( I tried to make simple request to page, that writes just is user authenticated, but it returns false even if I set UseDefaultCredentials true.. – lenden Jul 10 '12 at 12:43
  • I thing I have some server problem, because when I request vk.com it is authorized even without UseDefaultCredentials – lenden Jul 11 '12 at 08:17