locked
how to use httpwebrequest to get authentication based rss feed RRS feed

  • Question

  • User169649310 posted

    I have a application page in asp.net in code behind i am using httpwebrequest to get the rss feed from a local source. The problen is rss feed is user specific for the logged in user in the application. but i am not able to pass the credentials for the logged in user to the httpwebrequest.credentials object 

     

    I have tried using thedefaultnetworkcredentials but it gives the credentials for the applicationpoolaccount always so feed is coming for the wrong user. If i use new Networkcredentials("username",password, domain) and pass the details then i get the correct result, but i can not ask the user to login again and give the password.

     

    I have googled a lot found some ways like setting httpwebrequest properties using  cookiecontainer and other properties all in vain.

    Is there no way i can get the rss feed for the user. 

    Any help would be appreciated.

    Thanks in advance

    Thursday, February 2, 2012 12:05 PM

Answers

  • User-1935546128 posted

    Hi

    The only solution here will be impersonation:

    System.Security.Principal.WindowsImpersonationContext impersonationContext = ((System.Security.Principal.WindowsIdentityUser.Identity).Impersonate(); 
     
    //Here you can put the code for accessing RSS feed, DefaultNetworkCredentials should contain what you need 
     
    impersonationContext.Undo(); 
    

    A little bit more reading about impersonation: http://support.microsoft.com/kb/306158

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 3, 2012 2:35 PM