Calling Web Service from a C# Console application. The website is secure with form Authentication
I have a asp.net MVC 2 website. I would like to call a web page (http://localhost/main/SendEmail) with a C# Console Application.
Is there a way to do this ?
In summary
1 - C# Application Console Call A method in the website /main/SendEmail. 2 - The website is secure with Form authentication 3 - I don't want to use the anonymous attribute, we need authent开发者_开发问答icate the user.Does the webpage you are calling require an authenticated user? If not, you could allow anonymous access to just that URL in the web.config:
<location path="main/SendEmail">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
So first you have to post your credentials to the login page. Be sure to record all the cookies from the resultant HttpResponse. In all subsequent HttpRequests be sure to pass in all the recorded cookies.
That should do it.
精彩评论