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

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

2 Comments

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..
I thing I have some server problem, because when I request vk.com it is authorized even without UseDefaultCredentials

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.