-1

How to receive asp.net/C# variable values inside web.config?? Is there any way?

Under,

<identity impersonate="true" userName="hcltech\Loggedonusername" password="LoggedonUserPasswd" />

How to receive log in credentials inside web.config?..Please help

David
  • 208,112
  • 36
  • 198
  • 279

1 Answers1

0

How to receive asp.net/C# variable values inside web.config?? Is there any way?

No, there is not.

There is no point in impersonating the user that is logged in already, because they are logged in already. Impersonation is for giving the current user the permissions of a different Windows user.

NightOwl888
  • 55,572
  • 24
  • 139
  • 212
  • Hi, thanks for the reply..Our web Application generates a microsoft word document after receiving inputs from the front end..It has been hosted in windows 2008 R2 server..and as mentioned we have included the impersonation piece of code in web.config hardcoding username and passwd inside it..Now we are receiving a peculiar problem...If the application is run when the server is no logged off(v r sure not shuting it dwn), the application throws a error when it itries to create a word document..Really ur help ll b appreciated – Devananth Somasundaram Mar 05 '15 at 05:20
  • I am not sure if it is the best way, but for a problem like that I typically change the user of the application pool to a specifc user that has the rights to create files in a specific folder. However, it is unclear whether you actually need to create to create a physical file. It is usually easier to just create a binary stream with the right mime type so you don't have to mess with Windows permissions. See http://stackoverflow.com/questions/10667513/streaming-in-memory-word-document-using-openxml-sdk-w-asp-net-results-in-corrup – NightOwl888 Mar 05 '15 at 05:30
  • Actually, we are creating a word document using .net web application, whoever access this app from anywhere also has to create the document giving some inputs..it is hosted in server now, the document s geeting generated nd saved in the server, which we are making it as downloadle to client machines through a typical 'open,save' pop up..but all these happens oly when someone is loggee into the server..otherwise, till getting the user inputs the app works, as soon as the user clicks the 'Generate button' this problem comes – Devananth Somasundaram Mar 05 '15 at 05:42